From 0e48766a6853a3ab963ac5d2e33db12632111e19 Mon Sep 17 00:00:00 2001 From: jpekkila Date: Fri, 14 Jun 2019 14:18:35 +0300 Subject: [PATCH] Added Astaroth 2.0 --- 3rdparty/setup_dependencies.sh | 17 + CMakeLists.txt | 172 ++ LICENCE.txt | 18 + README.md | 118 +- acc/.gitignore | 5 + acc/README.md | 42 + acc/build_acc.sh | 25 + acc/clean.sh | 5 + acc/compile.sh | 24 + acc/mhd_solver/stencil_assembly.sas | 26 + acc/mhd_solver/stencil_process.sps | 265 ++ acc/preprocess.sh | 4 + acc/pseudodisk/stencil_process_gravx.sps | 228 ++ .../stencil_process_isotherm_gravx.sps | 169 ++ .../stencil_process_isotherm_linegrav.sps | 174 ++ acc/pseudodisk/stencil_process_linegrav.sps | 233 ++ acc/samples/common_header.h | 422 +++ acc/samples/sample_stencil_assembly.sas | 49 + acc/samples/sample_stencil_process.sps | 149 + acc/src/acc.l | 56 + acc/src/acc.y | 234 ++ acc/src/ast.h | 126 + acc/src/code_generator.c | 569 ++++ acc/test_grammar.sh | 48 + analysis/python/.gitignore | 1 + analysis/python/README.md | 7 + analysis/python/add_to_pythonpath.sh | 3 + analysis/python/astar/__init__.py | 24 + analysis/python/astar/data/__init__.py | 21 + analysis/python/astar/data/read.py | 142 + analysis/python/astar/visual/__init__.py | 21 + analysis/python/astar/visual/slices.py | 92 + analysis/python/calc/convert.sh | 9 + analysis/python/calc/galli_shu_plotter.py | 835 ++++++ analysis/python/calc/purge.sh | 1 + analysis/python/calc/shu_selfsim.py | 279 ++ analysis/python/purgepng.sh | 1 + analysis/python/samples/README.md | 3 + analysis/python/samples/lnrhobound.py | 41 + analysis/python/samples/readtest.py | 260 ++ config/astaroth.conf | 54 + config/astaroth_pseudodisk.conf | 121 + doc/doxygen/.gitignore | 4 + doc/manual/manual.md | 131 + doxyfile | 2427 +++++++++++++++++ include/astaroth.h | 422 +++ scripts/ac_mkbuilddir.sh | 81 + scripts/auto_optimize.sh | 51 + scripts/buildtest.sh | 3 + scripts/compile_acc.sh | 52 + scripts/fix_style.sh | 9 + scripts/gen_rk3_threadblockconf.c | 60 + scripts/generate_doc.sh | 2 + sourceme.sh | 7 + src/core/CMakeLists.txt | 70 + src/core/astaroth.cu | 451 +++ src/core/device.cu | 309 +++ src/core/device.cuh | 82 + src/core/errchk.h | 112 + src/core/kernels/.gitignore | 2 + src/core/kernels/boundconds.cuh | 1363 +++++++++ src/core/kernels/kernels.cuh | 794 ++++++ src/core/kernels/reduce.cuh | 338 +++ src/core/kernels/rk3.cuh | 742 +++++ src/core/math_utils.h | 91 + src/standalone/CMakeLists.txt | 10 + src/standalone/autotest.cc | 732 +++++ src/standalone/benchmark.cc | 300 ++ src/standalone/config_loader.cc | 194 ++ src/standalone/config_loader.h | 34 + src/standalone/main.cc | 94 + src/standalone/model/host_memory.cc | 737 +++++ src/standalone/model/host_memory.h | 58 + src/standalone/model/host_timestep.cc | 63 + src/standalone/model/host_timestep.h | 32 + src/standalone/model/model_boundconds.cc | 487 ++++ src/standalone/model/model_boundconds.h | 31 + src/standalone/model/model_diff.h | 353 +++ src/standalone/model/model_reduce.cc | 203 ++ src/standalone/model/model_reduce.h | 37 + src/standalone/model/model_rk3.cc | 1044 +++++++ src/standalone/model/model_rk3.h | 33 + src/standalone/model/modelmesh.h | 36 + src/standalone/renderer.cc | 447 +++ src/standalone/run.h | 35 + src/standalone/simulation.cc | 339 +++ src/standalone/timer_hires.h | 64 + 87 files changed, 18058 insertions(+), 1 deletion(-) create mode 100755 3rdparty/setup_dependencies.sh create mode 100644 CMakeLists.txt create mode 100644 LICENCE.txt create mode 100644 acc/.gitignore create mode 100644 acc/README.md create mode 100755 acc/build_acc.sh create mode 100755 acc/clean.sh create mode 100755 acc/compile.sh create mode 100644 acc/mhd_solver/stencil_assembly.sas create mode 100644 acc/mhd_solver/stencil_process.sps create mode 100755 acc/preprocess.sh create mode 100644 acc/pseudodisk/stencil_process_gravx.sps create mode 100644 acc/pseudodisk/stencil_process_isotherm_gravx.sps create mode 100644 acc/pseudodisk/stencil_process_isotherm_linegrav.sps create mode 100644 acc/pseudodisk/stencil_process_linegrav.sps create mode 100644 acc/samples/common_header.h create mode 100644 acc/samples/sample_stencil_assembly.sas create mode 100644 acc/samples/sample_stencil_process.sps create mode 100644 acc/src/acc.l create mode 100644 acc/src/acc.y create mode 100644 acc/src/ast.h create mode 100644 acc/src/code_generator.c create mode 100755 acc/test_grammar.sh create mode 100644 analysis/python/.gitignore create mode 100644 analysis/python/README.md create mode 100644 analysis/python/add_to_pythonpath.sh create mode 100644 analysis/python/astar/__init__.py create mode 100644 analysis/python/astar/data/__init__.py create mode 100644 analysis/python/astar/data/read.py create mode 100644 analysis/python/astar/visual/__init__.py create mode 100644 analysis/python/astar/visual/slices.py create mode 100755 analysis/python/calc/convert.sh create mode 100644 analysis/python/calc/galli_shu_plotter.py create mode 100755 analysis/python/calc/purge.sh create mode 100644 analysis/python/calc/shu_selfsim.py create mode 100755 analysis/python/purgepng.sh create mode 100644 analysis/python/samples/README.md create mode 100644 analysis/python/samples/lnrhobound.py create mode 100644 analysis/python/samples/readtest.py create mode 100644 config/astaroth.conf create mode 100644 config/astaroth_pseudodisk.conf create mode 100644 doc/doxygen/.gitignore create mode 100644 doc/manual/manual.md create mode 100644 doxyfile create mode 100644 include/astaroth.h create mode 100755 scripts/ac_mkbuilddir.sh create mode 100755 scripts/auto_optimize.sh create mode 100755 scripts/buildtest.sh create mode 100755 scripts/compile_acc.sh create mode 100755 scripts/fix_style.sh create mode 100644 scripts/gen_rk3_threadblockconf.c create mode 100755 scripts/generate_doc.sh create mode 100644 sourceme.sh create mode 100644 src/core/CMakeLists.txt create mode 100644 src/core/astaroth.cu create mode 100644 src/core/device.cu create mode 100644 src/core/device.cuh create mode 100644 src/core/errchk.h create mode 100644 src/core/kernels/.gitignore create mode 100644 src/core/kernels/boundconds.cuh create mode 100644 src/core/kernels/kernels.cuh create mode 100644 src/core/kernels/reduce.cuh create mode 100644 src/core/kernels/rk3.cuh create mode 100644 src/core/math_utils.h create mode 100644 src/standalone/CMakeLists.txt create mode 100644 src/standalone/autotest.cc create mode 100644 src/standalone/benchmark.cc create mode 100644 src/standalone/config_loader.cc create mode 100644 src/standalone/config_loader.h create mode 100644 src/standalone/main.cc create mode 100644 src/standalone/model/host_memory.cc create mode 100644 src/standalone/model/host_memory.h create mode 100644 src/standalone/model/host_timestep.cc create mode 100644 src/standalone/model/host_timestep.h create mode 100644 src/standalone/model/model_boundconds.cc create mode 100644 src/standalone/model/model_boundconds.h create mode 100644 src/standalone/model/model_diff.h create mode 100644 src/standalone/model/model_reduce.cc create mode 100644 src/standalone/model/model_reduce.h create mode 100644 src/standalone/model/model_rk3.cc create mode 100644 src/standalone/model/model_rk3.h create mode 100644 src/standalone/model/modelmesh.h create mode 100644 src/standalone/renderer.cc create mode 100644 src/standalone/run.h create mode 100644 src/standalone/simulation.cc create mode 100644 src/standalone/timer_hires.h diff --git a/3rdparty/setup_dependencies.sh b/3rdparty/setup_dependencies.sh new file mode 100755 index 0000000..3eec468 --- /dev/null +++ b/3rdparty/setup_dependencies.sh @@ -0,0 +1,17 @@ +#!/bin/bash +INITIAL_DIR=$(pwd) + + +# Fetch SDL2 +git clone https://github.com/davidsiaw/SDL2.git +cd SDL2 +git pull +mkdir build +cd build && cmake .. && make -j + +# See https://github.com/davidsiaw/SDL2/blob/master/docs/README-linux.md +# if there are isses with building + + +# Done +cd $INITIAL_DIR diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4b20ce8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,172 @@ +# +# CMakeLists.txt for generating the makefile for Astaroth. +# Usage: mkdir build && cd build && cmake .. +# +# For example: cmake -DDOUBLE_PRECISION=ON .. +# +# If you want to see the exact flags used during compilation, run +# "make -j VERBOSE=1" +# +# Make sure your machine satisfies the system requirements: +# https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements + +#-------------------General---------------------------------------------------# + +project(ASTAROTH_2.0 CXX) +set (CMAKE_CXX_STANDARD 98) +cmake_minimum_required (VERSION 3.5.1) # Need >= 3.8 for first-class CUDA support +cmake_policy (SET CMP0023 NEW) + + +#-------------------Set user options with default values---------------------# + +#Usage f.ex. cmake -DBUILD_DEBUG=ON .. +option(BUILD_DEBUG "Builds the program with extensive error checking" OFF) +option(BUILD_STANDALONE "Builds standalone Astaroth" ON) +option(DOUBLE_PRECISION "Generates double precision code" OFF) +option(TIARA_CLUSTER "Special settings for compilation TIARA GPU cluster" OFF) +option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON) +option(ALTER_CONF "If enabled, loads astaroth.conf from the build directory" OFF) + +#-------------------Determine build type--------------------------------------# + +#Available types (case-sensitive): +#RELEASE (best performance) +#DEBUG (w/ debug information, non-concurrent kernels) +if (BUILD_DEBUG) + set(CMAKE_BUILD_TYPE DEBUG) +else () + set(CMAKE_BUILD_TYPE RELEASE) +endif() +message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) + + +#----------------------Find packages------------------------------------------# + +# C++ compiler info +message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER}) +message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER_ID}) + +# SDL 2 +set(SDL2_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/SDL2/include/) +set(SDL2_LIBRARY_DIR ${CMAKE_SOURCE_DIR}/3rdparty/SDL2/build/) +set(SDL2_LIBRARY "SDL2") +include_directories(${SDL2_INCLUDE_DIR}) +link_directories(${SDL2_LIBRARY_DIR}) + +# CUDA +find_package(CUDA) +if (NOT CUDA_FOUND) + # find_package(CUDA REQUIRED) gives a confusing error message if it fails, + # therefore we print the reason here explicitly + message(FATAL_ERROR "CUDA not found") +endif() +include_directories(${CUDA_INCLUDE_DIRS}) + +# OpenMP +find_package(OpenMP) +if (NOT OPENMP_FOUND) + message(WARNING "OpenMP not found. All host-side concurrency disabled \ + (lower performance).") +else () + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") +endif() + +#----------------------Compilation settings-----------------------------------# + +#Debug and verification +#set(CMAKE_VERBOSE_MAKEFILE OFF) +#set(CXX_VERBOSE_BUILD OFF) +#set(CUDA_VERBOSE_BUILD OFF) +#include(CTest) +#add_test(ac_test ac_run) +#find_program(MEMORYCHECK_COMMAND valgrind) +#set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full" ) + + +#----------------------Setup defines------------------------------------------# + +if (DOUBLE_PRECISION) + add_definitions(-DAC_DOUBLE_PRECISION=1) +else() + add_definitions(-DAC_DOUBLE_PRECISION=0) +endif() + +# A full integration step is benchmarked by default, use this flag to override and +# benchmark RK3 only +if (GEN_BENCHMARK_RK3) + add_definitions(-DGEN_BENCHMARK_RK3=1) +else() + add_definitions(-DGEN_BENCHMARK_RK3=0) +endif() + +if (MULTIGPU_ENABLED) + add_definitions(-DAC_MULTIGPU_ENABLED=1) +else() + add_definitions(-DAC_MULTIGPU_ENABLED=0) +endif() + +#-----------------------TIARA specific options--------------------------------# +#OLD#set (CXX_FLAGS_TIARA "-I/software/opt/cuda/9.0/include/") +# %JP: NOTE! This should not be needed anymore because the command +# find_package(CUDA) above should find and include this directory automatically +#USE THIS: +if (TIARA_CLUSTER) + set (CXX_FLAGS_TIARA "-mno-bmi2") +endif() + +#----------------------Setup CXX compilation flags----------------------------# +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}\ + -O2 -march=native -pipe") + +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}\ + -O0 -g") + +set (CXX_FLAGS_WARNING "-Wall -Wextra -Werror -Wno-error=unused-parameter\ + -Wno-error=unused-function -Wno-error=unknown-pragmas") + +# Also warn about implicit conversions if the compiler supports it +if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + set (CXX_FLAGS_WARNING "${CXX_FLAGS_WARNING} -Wdouble-promotion -Wfloat-conversion") +endif() + +# Other flags. -D_FORCE_INLINES is a workaround to some CUDA/C++ "feature" +# which botches the compilation ("memcpy was not declared in this scope") +# (Not required with cc >= 3.0) +#set(CXX_FLAGS_ETC "-D_FORCE_INLINES") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\ + ${CXX_FLAGS_WARNING}\ + ${CXX_FLAGS_ETC}\ + ${CXX_FLAGS_TIARA}") # %JP: CXX_FLAGS_TIARA should not be needed, + # see comments in "TIARA specific options" + +message("CXX_FLAGS: " ${CMAKE_CXX_FLAGS}) + + +#----------------------Setup core subdirectories------------------------------# + +#Include root directory (.) so that the following modules can include their +#parent dir (f.ex. #include "common/stuff.h" instead of "../common/stuff") +include_directories(.) +include_directories(include) +include_directories(src) + +# CUDA sources +add_subdirectory(src/core) + +#----------------------Link---------------------------------------------------# + +if (BUILD_STANDALONE) + #Define the config directory + if (ALTER_CONF) + set(ASTAROTH_CONF_PATH "${CMAKE_BINARY_DIR}/") + else() + set(ASTAROTH_CONF_PATH "${CMAKE_SOURCE_DIR}/config/") + endif() + + #Add additional subdirectories + add_subdirectory (src/standalone) + cuda_add_executable(ac_run src/standalone/main.cc) + target_link_libraries(ac_run astaroth_standalone astaroth_core ${SDL2_LIBRARY}) +endif() diff --git a/LICENCE.txt b/LICENCE.txt new file mode 100644 index 0000000..a36573e --- /dev/null +++ b/LICENCE.txt @@ -0,0 +1,18 @@ +/* + Copyright (C) 2014-2018, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +*/ diff --git a/README.md b/README.md index 462dc46..c358335 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,118 @@ -# Astaroth +# Astaroth - A Multi-GPU library for generic stencil computations + +Astaroth is a single-node multi-GPU library for multiphysics and other problems, which involve stencil computations in a discrete mesh. It's licenced under the terms of the GNU General Public Licence, version 3, or later (see [LICENCE.txt](https://bitbucket.org/miikkavaisala/astaroth-code/src/master/astaroth_2.0/LICENCE.txt)). Astaroth ships with a domain-specific language, that can be used to translate high-level representation of the stencil computations into a heavily inlined GPU pipeline. + +## System requirements + +NVIDIA GPU with >= 3.0 compute capability. See https://en.wikipedia.org/wiki/CUDA#GPUs_supported. + +## Building (3rd party libraries) + +1. `cd 3rdparty` +1. `./setup_dependencies.sh` Note: this may take some time. + +## Building (Astaroth 2.0) + +1. `cd astaroth_2.0/build` +1. `cmake -DDOUBLE_PRECISION=OFF -DBUILD_DEBUG=OFF ..` (Use `cmake -D CMAKE_C_COMPILER=icc -D CMAKE_CXX_COMPILER=icpc -DDOUBLE_PRECISION=OFF -DBUILD_DEBUG=OFF ..` if compiling on TIARA) +1. `../scripts/compile_acc.sh && make -j` +1. `./ac_run ` + +If you encounter issues, recheck that the 3rd party libraries were successfully built during the previous step. + +### Available options + +- `-s` simulation +- `-b` benchmark +- `-t` automated test (NOTE! This is expected to fail with the default configuration as there's no CPU model solution for forcing/entropy) + +By default, the program does a real-time visualization of the simulation domain. The camera and the initial conditions can be controller by `arrow keys`, `pgup`, `pgdown` and `spacebar`. + +## Generating documentation + +Run `doxygen doxyfile` in astaroth_2.0 directory. The generated files can be found in `doc/doxygen`. The main page of the documentation will be at `dox/doxygen/astaroth_doc_html/index.html`. + +## Formatting + +If you have clang-format, you may run `scripts/fix_style.sh`. This script will recursively fix style of all the source files down from the current working directory. The script will ask for a confirmation before making any changes. + +## Directory structure + +## Coding style. + +### In a nutshell +- Use [K&R indentation style](https://en.wikipedia.org/wiki/Indentation_style#K&R_style) and 4 space tabs. +- Line width is 100 characters +- Start function names after a linebreak in source files. +- [Be generous with `const` type qualifiers](https://isocpp.org/wiki/faq/const-correctness). +- When in doubt, see [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). + +### Header example: +```cpp +// Licence notice and doxygen description here +#pragma once +#include "avoid_including_headers_here.h" + +/** Doxygen comments */ +void global_function(void); +``` + + +### Source example: +```cpp +#include "parent_header.h" + +#include + +#include "other_headers.h" +#include "more_headers.h" + +typedef struct { + int data; +} SomeStruct; + +static inline int small_function(const SomeStruct& stuff) { return stuff.data; } + +// Pass constant structs always by reference (&) and use const type qualifier. +// Modified structs are always passed as pointers (*), never as references. +// Constant parameters should be on the left-hand side, while non-consts go to the right. +static void +local_function(const SomeStruct& constant_struct, SomeStruct* modified_struct) +{ + modified_struct->data = constant_struct.data; +} + +void +global_function(void) +{ + return; +} +``` +## Miikka's compilation notes + +Modules Modules usen when compiling when compiling + + * intel/2016 + * hdf5/1.8.16_openmpi_1.10.2_ic16.0 + * cmake/3.9.5 + * openmpi/1.10.2_ic16.0 + * gcc/5.3.0 + * cuda/9.0 + +Requires this gcc flag to compile: `-mno-bmi2` Otherwise you get assembler error! + +For stencil pre-processing `flex` and particularly `libfl` is required for `acc/code_generator.c` to compile. + +Need CUDA version 9.2 or above version. + +Comment out cudaGetDeviceCount(&num_devices) in astaroth.cu + +OLD: `astaroth_2.0/acc/build.sh` only work when each line is written individually. (**solution needed**) + + +(**These are here because I don't dare to delete them yet** OLD: Intel compiler does not get correct flags with cmake on default settings. +This worked with 1.0: `cmake -D CMAKE_C_COMPILER=icc -D CMAKE_CXX_COMPILER=icpc -DDOUBLE_PRECISION=OFF -DBUILD_DEBUG=OFF ..` +but not this time. Issue with calling c+11 + definin compiler flags correctly in nvcc. + +OLD: I need to put `-I/software/opt/cuda/9.0/include` into the ../CMakeLists.txt so that it compiles. ) diff --git a/acc/.gitignore b/acc/.gitignore new file mode 100644 index 0000000..bc4b7d8 --- /dev/null +++ b/acc/.gitignore @@ -0,0 +1,5 @@ +build +testbin + +# Except this file +!.gitignore diff --git a/acc/README.md b/acc/README.md new file mode 100644 index 0000000..6197fed --- /dev/null +++ b/acc/README.md @@ -0,0 +1,42 @@ +# Dependencies +## Debian/Ubuntu +`apt install flex bison build-essential` + +# Usage +* `./build_acc.sh # Builds the ASPL compiler (acc)` +* `./compile.sh <.sps or .sas source> # Compiles the given stage into CUDA` +* `./test.sh # Tries to compile the sample stages` +* `./clean.sh # Removed directories generated by build_acc.sh and test.sh` + +## Example + +- `./compile.sh src/stencil_assembly.sas # Generates stencil_assembly.cuh` +- `./compile.sh src/stencil_process.sps # Generates stencil_process.cuh` + +# What happens under the hood + +The compiler is made of a scanner (flex), parser (bison), implementation of the abstract syntax tree (AST) and a code generator. +The language is defined by tokens and grammars found in acc.l and acc.y. These files are given as input to flex and bison, which generate the scanning and parsing stages for the compiler. The resulting AST is defined in ast.h. Finally, we traverse the generated AST with our code generator, generating CUDA code. + +## ACC compilation stages + +### In short: +* Preprocess .ac +* Compile preprocessed .ac to .cuh +* Compile .cuh + +### More detailed: +0. A Parser is generated: bison --verbose -d acc.y +0. A Scanner is generated: flex acc.l +0. The compiler is built: gcc -std=gnu11 code_generator.c acc.tab.c lex.yy.c -lfl +0. Source files (.sps and .sas) are preprocessed using the GCC preprocessor and cleaned from any residual directives which would be useful when compiling the code further with GCC. We do not need those when compiling with ACC and are not recognized by our grammar. +0. Either the stencil processing stage (.sps) or the stencil assembly stage (.sas) are generated by passing the preprocessed file to acc. This emits the final CUDA code. +0. Compilation is continued with the NVIDIA CUDA compiler + +### Even more detailed: +The NVIDIA CUDA compiler compiles .cuh to .fatbin, which is embedded into a C++ binary containig host code of the program. A fatbin contains .cubin files, which contain the configuration of the GPU and the kernels in a streaming assembly code (.sass). We could also compile for a virtual architecture (.ptx) instead of the actual hardware-specific machine code (.cubin) by passing -code=compute_XX flag to nvcc, which would compile cuda sources at runtime (just-in-time compilation, JIT) when creating the CUDA context. However, we alway know which architecture we want to run the code on and JIT compilation would just increase the time to takes to launch the program. + +nvcc -DAC_DOUBLE_PRECISION=1 -ptx --relocatable-device-code true -O3 -std=c++11 --maxrregcount=255 -ftz=true -gencode arch=compute_60,code=sm_60 device.cu -I ../../include -I ../../ +nvcc -DAC_DOUBLE_PRECISION=1 -cubin --relocatable-device-code true -O3 -std=c++11 --maxrregcount=255 -ftz=true -gencode arch=compute_60,code=sm_60 device.cu -I ../../include -I ../../ +cuobjdump --dump-sass device.cubin > device.sass + diff --git a/acc/build_acc.sh b/acc/build_acc.sh new file mode 100755 index 0000000..ed275d5 --- /dev/null +++ b/acc/build_acc.sh @@ -0,0 +1,25 @@ +#!/bin/bash +cd `dirname $0` # Only operate in the same directory with this script + +COMPILER_NAME="acc" + +SRC_DIR=${PWD}/src +BUILD_DIR=${PWD}/build + +echo "Created" ${BUILD_DIR} + +mkdir -p ${BUILD_DIR} +cd ${BUILD_DIR} + +echo ${BASE_DIR} +echo ${SRC_DIR} +echo ${BUILD_DIR} + +# Generate Bison headers +bison --verbose -d ${SRC_DIR}/${COMPILER_NAME}.y + +## Generate Flex sources and headers +flex ${SRC_DIR}/${COMPILER_NAME}.l + +## Compile the ASPL compiler +gcc -std=gnu11 ${SRC_DIR}/code_generator.c ${COMPILER_NAME}.tab.c lex.yy.c -lfl -I ${BUILD_DIR} -I ${SRC_DIR} -o ${COMPILER_NAME} diff --git a/acc/clean.sh b/acc/clean.sh new file mode 100755 index 0000000..ad012c4 --- /dev/null +++ b/acc/clean.sh @@ -0,0 +1,5 @@ +#!/bin/bash +cd `dirname $0` # Only operate in the same directory with this script + +rm -rf build testbin + diff --git a/acc/compile.sh b/acc/compile.sh new file mode 100755 index 0000000..55831cd --- /dev/null +++ b/acc/compile.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Usage ./compile + +ACC_DIR=`dirname $0` + +FULL_NAME=$(basename -- $1) +FILENAME="${FULL_NAME%.*}" +EXTENSION="${FULL_NAME##*.}" + +if [ "${EXTENSION}" = "sas" ]; then + echo "Generating stencil assembly stage ${FILENAME}.sas -> stencil_assembly.cuh" + COMPILE_FLAGS="-sas" # Generate stencil assembly stage + CUH_FILENAME="stencil_assembly.cuh" +elif [ "${EXTENSION}" = "sps" ]; then + echo "Generating stencil processing stage: ${FILENAME}.sps -> stencil_process.cuh" + COMPILE_FLAGS="-sps" # Generate stencil processing stage + CUH_FILENAME="stencil_process.cuh" +else + echo "Error: unknown extension" ${EXTENSION} "of file" ${FULL_NAME} + echo "Extension should be either .sas or .sps" + exit +fi + +${ACC_DIR}/preprocess.sh $1 | ${ACC_DIR}/build/acc ${COMPILE_FLAGS} > ${CUH_FILENAME} diff --git a/acc/mhd_solver/stencil_assembly.sas b/acc/mhd_solver/stencil_assembly.sas new file mode 100644 index 0000000..f9025f9 --- /dev/null +++ b/acc/mhd_solver/stencil_assembly.sas @@ -0,0 +1,26 @@ + +Preprocessed Scalar +value(in Scalar vertex) +{ + return vertex[vertexIdx]; +} + +Preprocessed Vector +gradient(in Scalar vertex) +{ + return (Vector){derx(vertexIdx, vertex), + dery(vertexIdx, vertex), + derz(vertexIdx, vertex)}; +} + +Preprocessed Matrix +hessian(in Scalar vertex) +{ + Matrix hessian; + + hessian.row[0] = (Vector){derxx(vertexIdx, vertex), derxy(vertexIdx, vertex), derxz(vertexIdx, vertex)}; + hessian.row[1] = (Vector){hessian.row[0].y, deryy(vertexIdx, vertex), deryz(vertexIdx, vertex)}; + hessian.row[2] = (Vector){hessian.row[0].z, hessian.row[1].z, derzz(vertexIdx, vertex)}; + + return hessian; +} diff --git a/acc/mhd_solver/stencil_process.sps b/acc/mhd_solver/stencil_process.sps new file mode 100644 index 0000000..520ceb5 --- /dev/null +++ b/acc/mhd_solver/stencil_process.sps @@ -0,0 +1,265 @@ +#define LINDUCTION (1) +#define LENTROPY (1) +#define LTEMPERATURE (0) +#define LGRAVITY (0) + + +// Declare uniforms (i.e. device constants) +uniform Scalar cs2_sound; +uniform Scalar nu_visc; +uniform Scalar cp_sound; +uniform Scalar cv_sound; +uniform Scalar mu0; +uniform Scalar eta; +uniform Scalar gamma; +uniform Scalar zeta; + +uniform int nx_min; +uniform int ny_min; +uniform int nz_min; +uniform int nx; +uniform int ny; +uniform int nz; + +Vector +value(in Vector uu) +{ + return (Vector){value(uu.x), value(uu.y), value(uu.z)}; +} + +Matrix +gradients(in Vector uu) +{ + return (Matrix){gradient(uu.x), gradient(uu.y), gradient(uu.z)}; +} + +Scalar +continuity(in Vector uu, in Scalar lnrho) { + return -dot(value(uu), gradient(lnrho)) - divergence(uu); +} + +#if LENTROPY +Vector +momentum(in Vector uu, in Scalar lnrho, in Scalar ss, in Vector aa) { + const Matrix S = stress_tensor(uu); + const Scalar cs2 = cs2_sound * exp(gamma * value(ss) / cp_sound + (gamma - 1) * (value(lnrho) - LNRHO0)); + const Vector j = (Scalar(1.) / mu0) * (gradient_of_divergence(aa) - laplace_vec(aa)); // Current density + const Vector B = curl(aa); + const Scalar inv_rho = Scalar(1.) / exp(value(lnrho)); + + // Regex replace CPU constants with get\(AC_([a-zA-Z_0-9]*)\) + // \1 + const Vector mom = - mul(gradients(uu), value(uu)) + - cs2 * ((Scalar(1.) / cp_sound) * gradient(ss) + gradient(lnrho)) + + inv_rho * cross(j, B) + + nu_visc * ( + laplace_vec(uu) + + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho)) + ) + + zeta * gradient_of_divergence(uu); + return mom; +} +#elif LTEMPERATURE +Vector +momentum(in Vector uu, in Scalar lnrho, in Scalar tt) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + const Vector pressure_term = (cp_sound - cv_sound) * (gradient(tt) + value(tt) * gradient(lnrho)); + + mom = -mul(gradients(uu), value(uu)) - + pressure_term + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu); + + #if LGRAVITY + mom = mom - (Vector){0, 0, -10.0}; + #endif + + return mom; +} +#else +Vector +momentum(in Vector uu, in Scalar lnrho) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + // Isothermal: we have constant speed of sound + + mom = -mul(gradients(uu), value(uu)) - + cs2_sound * gradient(lnrho) + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu); + + #if LGRAVITY + mom = mom - (Vector){0, 0, -10.0}; + #endif + + return mom; +} +#endif + + +Vector +induction(in Vector uu, in Vector aa) { + // Note: We do (-nabla^2 A + nabla(nabla dot A)) instead of (nabla x (nabla + // x A)) in order to avoid taking the first derivative twice (did the math, + // yes this actually works. See pg.28 in arXiv:astro-ph/0109497) + // u cross B - ETA * mu0 * (mu0^-1 * [- laplace A + grad div A ]) + const Vector B = curl(aa); + const Vector grad_div = gradient_of_divergence(aa); + const Vector lap = laplace_vec(aa); + + // Note, mu0 is cancelled out + const Vector ind = cross(value(uu), B) - eta * (grad_div - lap); + + return ind; +} + + +#if LENTROPY +Scalar +lnT( in Scalar ss, in Scalar lnrho) { + const Scalar lnT = LNT0 + gamma * value(ss) / cp_sound + + (gamma - Scalar(1.)) * (value(lnrho) - LNRHO0); + return lnT; +} + +// Nabla dot (K nabla T) / (rho T) +Scalar +heat_conduction( in Scalar ss, in Scalar lnrho) { + const Scalar inv_cp_sound = AcReal(1.) / cp_sound; + + const Vector grad_ln_chi = - gradient(lnrho); + + const Scalar first_term = gamma * inv_cp_sound * laplace(ss) + + (gamma - AcReal(1.)) * laplace(lnrho); + const Vector second_term = gamma * inv_cp_sound * gradient(ss) + + (gamma - AcReal(1.)) * gradient(lnrho); + const Vector third_term = gamma * (inv_cp_sound * gradient(ss) + + gradient(lnrho)) + grad_ln_chi; + + const Scalar chi = AC_THERMAL_CONDUCTIVITY / (exp(value(lnrho)) * cp_sound); + return cp_sound * chi * (first_term + dot(second_term, third_term)); +} + +Scalar +heating(const int i, const int j, const int k) { + return 1; +} + +Scalar +entropy(in Scalar ss, in Vector uu, in Scalar lnrho, in Vector aa) { + const Matrix S = stress_tensor(uu); + const Scalar inv_pT = Scalar(1.) / (exp(value(lnrho)) * exp(lnT(ss, lnrho))); + const Vector j = (Scalar(1.) / mu0) * (gradient_of_divergence(aa) - laplace_vec(aa)); // Current density + const Scalar RHS = H_CONST - C_CONST + + eta * (mu0) * dot(j, j) + + Scalar(2.) * exp(value(lnrho)) * nu_visc * contract(S) + + zeta * exp(value(lnrho)) * divergence(uu) * divergence(uu); + + return - dot(value(uu), gradient(ss)) + + inv_pT * RHS + + heat_conduction(ss, lnrho); +} +#endif + +#if LTEMPERATURE +Scalar +heat_transfer(in Vector uu, in Scalar lnrho, in Scalar tt) +{ + const Matrix S = stress_tensor(uu); + const Scalar heat_diffusivity_k = 0.0008; //8e-4; + return -dot(value(uu), gradient(tt)) + heat_diffusivity_k * laplace(tt) + heat_diffusivity_k * dot(gradient(lnrho), gradient(tt)) + nu_visc * contract(S) * (Scalar(1.) / cv_sound) - (gamma - 1) * value(tt) * divergence(uu); +} +#endif + +// Declare input and output arrays using locations specified in the +// array enum in astaroth.h +in Scalar lnrho = VTXBUF_LNRHO; +out Scalar out_lnrho = VTXBUF_LNRHO; + +in Vector uu = (int3) {VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ}; +out Vector out_uu = (int3) {VTXBUF_UUX,VTXBUF_UUY,VTXBUF_UUZ}; + + +#if LINDUCTION +in Vector aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +out Vector out_aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +#endif + +#if LENTROPY +in Scalar ss = VTXBUF_ENTROPY; +out Scalar out_ss = VTXBUF_ENTROPY; +#endif + +#if LTEMPERATURE +in Scalar tt = VTXBUF_TEMPERATURE; +out Scalar out_tt = VTXBUF_TEMPERATURE; +#endif + +Kernel void +solve(Scalar dt) { + out_lnrho = rk3(out_lnrho, lnrho, continuity(uu, lnrho), dt); + + #if LINDUCTION + out_aa = rk3(out_aa, aa, induction(uu, aa), dt); + #endif + + #if LENTROPY + out_uu = rk3(out_uu, uu, momentum(uu, lnrho, ss, aa), dt); + out_ss = rk3(out_ss, ss, entropy(ss, uu, lnrho, aa), dt); + #elif LTEMPERATURE + out_uu =rk3(out_uu, uu, momentum(uu, lnrho, tt), dt); + out_tt = rk3(out_tt, tt, heat_transfer(uu, lnrho, tt), dt); + #else + out_uu = rk3(out_uu, uu, momentum(uu, lnrho), dt); + #endif +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/acc/preprocess.sh b/acc/preprocess.sh new file mode 100755 index 0000000..0ce6fbc --- /dev/null +++ b/acc/preprocess.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Preprocesses the give file using GCC. This script is usually automatically called in +# ./compile.sh, but may be called also individually for debugging purposes. +gcc -E -x c ${@} | sed "s/#.*//g" diff --git a/acc/pseudodisk/stencil_process_gravx.sps b/acc/pseudodisk/stencil_process_gravx.sps new file mode 100644 index 0000000..32d980a --- /dev/null +++ b/acc/pseudodisk/stencil_process_gravx.sps @@ -0,0 +1,228 @@ +#define LINDUCTION (1) +#define LENTROPY (1) + + +// Declare uniforms (i.e. device constants) +uniform Scalar cs2_sound; +uniform Scalar nu_visc; +uniform Scalar cp_sound; +uniform Scalar mu0; +uniform Scalar eta; +uniform Scalar gamma; +uniform Scalar chi; +uniform Scalar zeta; + +uniform int nx_min; +uniform int ny_min; +uniform int nz_min; +uniform int nx; +uniform int ny; +uniform int nz; + +uniform Scalar xorig; +uniform Scalar yorig; +uniform Scalar zorig; + +//Star position +uniform Scalar star_pos_x; +uniform Scalar star_pos_z; +uniform Scalar GM_star; + +//Needed for gravity +uniform Scalar dsx; +uniform Scalar dsy; +uniform Scalar dsz; +uniform Scalar inv_dsx; +uniform Scalar inv_dsy; +uniform Scalar inv_dsz; + +Scalar +distance_x(Vector a, Vector b) +{ + return sqrt(dot(a-b, a-b)); +} + +Vector +value(in Vector uu) +{ + return (Vector){value(uu.x), value(uu.y), value(uu.z)}; +} + +Matrix +gradients(in Vector uu) +{ + return (Matrix){gradient(uu.x), gradient(uu.y), gradient(uu.z)}; +} + +Scalar +continuity(in Vector uu, in Scalar lnrho) { + return -dot(value(uu), gradient(lnrho)) - divergence(uu); +} + +// Gravitation for in negative x-direction. +Vector +grav_force_line(const int3 vertexIdx) +{ + Vector vertex_pos = (Vector){dsx * vertexIdx.x - xorig, dsy * vertexIdx.y - yorig, dsz * vertexIdx.z - zorig}; + Vector star_pos = (Vector){star_pos_x, dsy * vertexIdx.y - yorig, dsz * vertexIdx.z - zorig}; + + const Scalar RR = vertex_pos.x - star_pos.x; + + const Scalar G_force_abs = GM_star / (RR*RR); // Force per unit mass; + + Vector G_force = (Vector){ - G_force_abs, + AcReal(0.0), + AcReal(0.0)}; + + return G_force; +} + +#if LENTROPY +Vector +momentum(in Vector uu, in Scalar lnrho, in Scalar ss, in Vector aa, const int3 vertexIdx) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + mom = -mul(gradients(uu), value(uu)) - + cs2_sound * gradient(lnrho) + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu); + + mom = mom - cs2_sound * (Scalar(1.) / cp_sound) * gradient(ss); + + const Vector grad_div = gradient_of_divergence(aa); + const Vector lap = laplace_vec(aa); + const Vector j = (Scalar(1.) / mu0) * (grad_div - lap); + const Vector B = curl(aa); + mom = mom + (Scalar(1.) / exp(value(lnrho))) * cross(j, B); + + mom = mom + grav_force_line(vertexIdx); + + return mom; +} +#else +Vector +momentum(in Vector uu, in Scalar lnrho, const int3 vertexIdx) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + mom = -mul(gradients(uu), value(uu)) - + cs2_sound * gradient(lnrho) + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu); + + mom = mom + grav_force_line(vertexIdx); + + return mom; +} +#endif + + +Vector +induction(in Vector uu, in Vector aa) { + // Note: We do (-nabla^2 A + nabla(nabla dot A)) instead of (nabla x (nabla + // x A)) in order to avoid taking the first derivative twice (did the math, + // yes this actually works. See pg.28 in arXiv:astro-ph/0109497) + // u cross B - ETA * mu0 * (mu0^-1 * [- laplace A + grad div A ]) + const Vector B = curl(aa); + const Vector grad_div = gradient_of_divergence(aa); + const Vector lap = laplace_vec(aa); + + // Note, mu0 is cancelled out + const Vector ind = cross(value(uu), B) - eta * (grad_div - lap); + + return ind; +} + + +#if LENTROPY +Scalar +lnT( in Scalar ss, in Scalar lnrho) { + const Scalar lnT = LNT0 + value(ss) / cp_sound + + (gamma - AcReal(1.)) * (value(lnrho) - LNRHO0); + return lnT; +} + +// Nabla dot (K nabla T) / (rho T) +Scalar +heat_conduction( in Scalar ss, in Scalar lnrho) { + const Scalar inv_cp_sound = AcReal(1.) / cp_sound; + + const Vector grad_ln_chi = (Vector) { + 0, + 0, + 0 + }; // TODO not used + + const Scalar first_term = gamma * inv_cp_sound * laplace(ss) + + (gamma - AcReal(1.)) * laplace(lnrho); + const Vector second_term = gamma * inv_cp_sound * gradient(ss) + + (gamma - AcReal(1.)) * gradient(lnrho); + const Vector third_term = gamma * (inv_cp_sound * gradient(ss) + + gradient(lnrho)) + grad_ln_chi; + + return cp_sound * chi * (first_term + dot(second_term, third_term)); +} + +Scalar +heating(const int i, const int j, const int k) { + return 1; +} + +Scalar +entropy(in Scalar ss, in Vector uu, in Scalar lnrho, in Vector aa) { + const Matrix S = stress_tensor(uu); + + // nabla x nabla x A / mu0 = nabla(nabla dot A) - nabla^2(A) + const Vector j = gradient_of_divergence(aa) - laplace_vec(aa); + + const Scalar inv_pT = AcReal(1.) / (exp(value(lnrho)) + exp(lnT(ss, lnrho))); + + return -dot(value(uu), gradient(ss)) + + inv_pT * (H_CONST - C_CONST + + eta * mu0 * dot(j, j) + + AcReal(2.) * exp(value(lnrho)) * nu_visc * contract(S) + + zeta * exp(value(lnrho)) * divergence(uu) * divergence(uu) + ) + heat_conduction(ss, lnrho); +} +#endif + +// Declare input and output arrays using locations specified in the +// array enum in astaroth.h +in Scalar lnrho = VTXBUF_LNRHO; +out Scalar out_lnrho = VTXBUF_LNRHO; + +in Vector uu = (int3) {VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ}; +out Vector out_uu = (int3) {VTXBUF_UUX,VTXBUF_UUY,VTXBUF_UUZ}; + + +#if LINDUCTION +in Vector aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +out Vector out_aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +#endif + +#if LENTROPY +in Scalar ss = VTXBUF_ENTROPY; +out Scalar out_ss = VTXBUF_ENTROPY; +#endif + +Kernel void +solve(Scalar dt) { + WRITE(out_lnrho, RK3(out_lnrho, lnrho, continuity(uu, lnrho), dt)); + + #if LINDUCTION + WRITE(out_aa, RK3(out_aa, aa, induction(uu, aa), dt)); + #endif + + + #if LENTROPY + WRITE(out_uu, RK3(out_uu, uu, momentum(uu, lnrho, ss, aa, vertexIdx), dt)); + WRITE(out_ss, RK3(out_ss, ss, entropy(ss, uu, lnrho, aa), dt)); + #else + WRITE(out_uu, RK3(out_uu, uu, momentum(uu, lnrho, vertexIdx), dt)); + #endif +} diff --git a/acc/pseudodisk/stencil_process_isotherm_gravx.sps b/acc/pseudodisk/stencil_process_isotherm_gravx.sps new file mode 100644 index 0000000..f79b7ff --- /dev/null +++ b/acc/pseudodisk/stencil_process_isotherm_gravx.sps @@ -0,0 +1,169 @@ + +// Declare uniforms (i.e. device constants) +uniform Scalar cs2_sound; +uniform Scalar nu_visc; +uniform Scalar cp_sound; +uniform Scalar mu0; +uniform Scalar eta; +uniform Scalar gamma; +uniform Scalar chi; +uniform Scalar zeta; + +uniform Scalar xorig; +uniform Scalar yorig; +uniform Scalar zorig; + +//Star position +uniform Scalar star_pos_x; +uniform Scalar star_pos_z; +uniform Scalar GM_star; + +uniform int nx_min; +uniform int ny_min; +uniform int nz_min; +uniform int nx; +uniform int ny; +uniform int nz; + +//Needed for gravity +uniform Scalar dsx; +uniform Scalar dsy; +uniform Scalar dsz; +uniform Scalar inv_dsx; +uniform Scalar inv_dsy; +uniform Scalar inv_dsz; + +Scalar +distance_x(Vector a, Vector b) +{ + return sqrt(dot(a-b, a-b)); +} + +Vector +value(in Vector uu) +{ + return (Vector){value(uu.x), value(uu.y), value(uu.z)}; +} + +Matrix +gradients(in Vector uu) +{ + return (Matrix){gradient(uu.x), gradient(uu.y), gradient(uu.z)}; +} + +Scalar +continuity(in Vector uu, in Scalar lnrho) { + return -dot(value(uu), gradient(lnrho)) - divergence(uu); +} + + +// "Line-like" gravity with no y-component +Vector +grav_force_line(const int3 vertexIdx) +{ + Vector vertex_pos = (Vector){dsx * vertexIdx.x - xorig, dsy * vertexIdx.y - yorig, dsz * vertexIdx.z - zorig}; + Vector star_pos = (Vector){star_pos_x, dsy * vertexIdx.y - yorig, dsz * vertexIdx.z - zorig}; + + const Scalar RR = vertex_pos.x - star_pos.x; + + const Scalar G_force_abs = GM_star / (RR*RR); // Force per unit mass; + + Vector G_force = (Vector){ - G_force_abs, + AcReal(0.0), + AcReal(0.0)}; + + return G_force; +} + + +Vector +momentum(in Vector uu, in Scalar lnrho, const int3 vertexIdx) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + mom = -mul(gradients(uu), value(uu)) - + cs2_sound * gradient(lnrho) + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu) + + grav_force_line(vertexIdx); + + + return mom; +} + +Vector +induction(in Vector uu, in Vector aa) { + // Note: We do (-nabla^2 A + nabla(nabla dot A)) instead of (nabla x (nabla + // x A)) in order to avoid taking the first derivative twice (did the math, + // yes this actually works. See pg.28 in arXiv:astro-ph/0109497) + // u cross B - ETA * mu0 * (mu0^-1 * [- laplace A + grad div A ]) + const Vector B = curl(aa); + const Vector grad_div = gradient_of_divergence(aa); + const Vector lap = laplace_vec(aa); + + // Note, mu0 is cancelled out + const Vector ind = cross(value(uu), B) - eta * (grad_div - lap); + + return ind; +} + +// Declare input and output arrays using locations specified in the +// array enum in astaroth.h +in Scalar lnrho = VTXBUF_LNRHO; +out Scalar out_lnrho = VTXBUF_LNRHO; + +in Vector uu = (int3) {VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ}; +out Vector out_uu = (int3) {VTXBUF_UUX,VTXBUF_UUY,VTXBUF_UUZ}; + +#if LINDUCTION +in Vector aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +out Vector out_aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +#endif + +Kernel void +solve(Scalar dt) { + WRITE(out_lnrho, RK3(out_lnrho, lnrho, continuity(uu, lnrho), dt)); + + #if LINDUCTION + WRITE(out_aa, RK3(out_aa, aa, induction(uu, aa), dt)); + #endif + + WRITE(out_uu, RK3(out_uu, uu, momentum(uu, lnrho, vertexIdx), dt)); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/acc/pseudodisk/stencil_process_isotherm_linegrav.sps b/acc/pseudodisk/stencil_process_isotherm_linegrav.sps new file mode 100644 index 0000000..a2b83f1 --- /dev/null +++ b/acc/pseudodisk/stencil_process_isotherm_linegrav.sps @@ -0,0 +1,174 @@ + +// Declare uniforms (i.e. device constants) +uniform Scalar cs2_sound; +uniform Scalar nu_visc; +uniform Scalar cp_sound; +uniform Scalar mu0; +uniform Scalar eta; +uniform Scalar gamma; +uniform Scalar chi; +uniform Scalar zeta; + +uniform Scalar xorig; +uniform Scalar yorig; +uniform Scalar zorig; + +//Star position +uniform Scalar star_pos_x; +uniform Scalar star_pos_z; +uniform Scalar GM_star; + +uniform int nx_min; +uniform int ny_min; +uniform int nz_min; +uniform int nx; +uniform int ny; +uniform int nz; + +//Needed for gravity +uniform Scalar dsx; +uniform Scalar dsy; +uniform Scalar dsz; +uniform Scalar inv_dsx; +uniform Scalar inv_dsy; +uniform Scalar inv_dsz; + +Scalar +distance(Vector a, Vector b) +{ + return sqrt(dot(a-b, a-b)); +} + +Vector +value(in Vector uu) +{ + return (Vector){value(uu.x), value(uu.y), value(uu.z)}; +} + +Matrix +gradients(in Vector uu) +{ + return (Matrix){gradient(uu.x), gradient(uu.y), gradient(uu.z)}; +} + +Scalar +continuity(in Vector uu, in Scalar lnrho) { + return -dot(value(uu), gradient(lnrho)) - divergence(uu); +} + + +// "Line-like" gravity with no y-component +Vector +grav_force_line(const int3 vertexIdx) +{ + Vector vertex_pos = (Vector){dsx * vertexIdx.x - xorig, dsy * vertexIdx.y - yorig, dsz * vertexIdx.z - zorig}; + //Vector star_pos = (Vector){star_pos_x - xorig, dsy * vertexIdx.y - yorig, star_pos_z - zorig}; + Vector star_pos = (Vector){star_pos_x, dsy * vertexIdx.y - yorig, star_pos_z}; + //LIKE THIS: Vector star_pos = (Vector){star_pos_x, 0.0, star_pos_z}; + + const Scalar RR = distance(star_pos, vertex_pos); + + const Scalar G_force_abs = GM_star / (RR*RR); // Force per unit mass; + //const Scalar G_force_abs = 1.0; // Simple temp. test; + + Vector G_force = (Vector){ - G_force_abs*((vertex_pos.x-star_pos.x)/RR), + AcReal(0.0), + - G_force_abs*((vertex_pos.z-star_pos.z)/RR)}; + + //printf("G_force %e %e %e", G_force_abs.x, G_force_abs.y, G_force_abs.z) + + return G_force; +} + + +Vector +momentum(in Vector uu, in Scalar lnrho, const int3 vertexIdx) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + mom = -mul(gradients(uu), value(uu)) - + cs2_sound * gradient(lnrho) + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu) + + grav_force_line(vertexIdx); + + + return mom; +} + +Vector +induction(in Vector uu, in Vector aa) { + // Note: We do (-nabla^2 A + nabla(nabla dot A)) instead of (nabla x (nabla + // x A)) in order to avoid taking the first derivative twice (did the math, + // yes this actually works. See pg.28 in arXiv:astro-ph/0109497) + // u cross B - ETA * mu0 * (mu0^-1 * [- laplace A + grad div A ]) + const Vector B = curl(aa); + const Vector grad_div = gradient_of_divergence(aa); + const Vector lap = laplace_vec(aa); + + // Note, mu0 is cancelled out + const Vector ind = cross(value(uu), B) - eta * (grad_div - lap); + + return ind; +} + +// Declare input and output arrays using locations specified in the +// array enum in astaroth.h +in Scalar lnrho = VTXBUF_LNRHO; +out Scalar out_lnrho = VTXBUF_LNRHO; + +in Vector uu = (int3) {VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ}; +out Vector out_uu = (int3) {VTXBUF_UUX,VTXBUF_UUY,VTXBUF_UUZ}; + +#if LINDUCTION +in Vector aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +out Vector out_aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +#endif + +Kernel void +solve(Scalar dt) { + WRITE(out_lnrho, RK3(out_lnrho, lnrho, continuity(uu, lnrho), dt)); + + #if LINDUCTION + WRITE(out_aa, RK3(out_aa, aa, induction(uu, aa), dt)); + #endif + + WRITE(out_uu, RK3(out_uu, uu, momentum(uu, lnrho, vertexIdx), dt)); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/acc/pseudodisk/stencil_process_linegrav.sps b/acc/pseudodisk/stencil_process_linegrav.sps new file mode 100644 index 0000000..ecc6c99 --- /dev/null +++ b/acc/pseudodisk/stencil_process_linegrav.sps @@ -0,0 +1,233 @@ +#define LINDUCTION (1) +#define LENTROPY (1) + + +// Declare uniforms (i.e. device constants) +uniform Scalar cs2_sound; +uniform Scalar nu_visc; +uniform Scalar cp_sound; +uniform Scalar mu0; +uniform Scalar eta; +uniform Scalar gamma; +uniform Scalar chi; +uniform Scalar zeta; + +uniform int nx_min; +uniform int ny_min; +uniform int nz_min; +uniform int nx; +uniform int ny; +uniform int nz; + +uniform Scalar xorig; +uniform Scalar yorig; +uniform Scalar zorig; + +//Star position +uniform Scalar star_pos_x; +uniform Scalar star_pos_z; +uniform Scalar GM_star; + +//Needed for gravity +uniform Scalar dsx; +uniform Scalar dsy; +uniform Scalar dsz; +uniform Scalar inv_dsx; +uniform Scalar inv_dsy; +uniform Scalar inv_dsz; + +Scalar +distance_x(Vector a, Vector b) +{ + return sqrt(dot(a-b, a-b)); +} + +Vector +value(in Vector uu) +{ + return (Vector){value(uu.x), value(uu.y), value(uu.z)}; +} + +Matrix +gradients(in Vector uu) +{ + return (Matrix){gradient(uu.x), gradient(uu.y), gradient(uu.z)}; +} + +Scalar +continuity(in Vector uu, in Scalar lnrho) { + return -dot(value(uu), gradient(lnrho)) - divergence(uu); +} + +// "Line-like" gravity with no y-component +Vector +grav_force_line(const int3 vertexIdx) +{ + Vector vertex_pos = (Vector){dsx * vertexIdx.x - xorig, dsy * vertexIdx.y - yorig, dsz * vertexIdx.z - zorig}; + //Vector star_pos = (Vector){star_pos_x - xorig, dsy * vertexIdx.y - yorig, star_pos_z - zorig}; + Vector star_pos = (Vector){star_pos_x, dsy * vertexIdx.y - yorig, star_pos_z}; + //LIKE THIS: Vector star_pos = (Vector){star_pos_x, 0.0, star_pos_z}; + + const Scalar RR = distance(star_pos, vertex_pos); + + const Scalar G_force_abs = GM_star / (RR*RR); // Force per unit mass; + //const Scalar G_force_abs = 1.0; // Simple temp. test; + + Vector G_force = (Vector){ - G_force_abs*((vertex_pos.x-star_pos.x)/RR), + AcReal(0.0), + - G_force_abs*((vertex_pos.z-star_pos.z)/RR)}; + + //printf("G_force %e %e %e", G_force_abs.x, G_force_abs.y, G_force_abs.z) + + return G_force; +} + +#if LENTROPY +Vector +momentum(in Vector uu, in Scalar lnrho, in Scalar ss, in Vector aa, const int3 vertexIdx) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + mom = -mul(gradients(uu), value(uu)) - + cs2_sound * gradient(lnrho) + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu); + + mom = mom - cs2_sound * (Scalar(1.) / cp_sound) * gradient(ss); + + const Vector grad_div = gradient_of_divergence(aa); + const Vector lap = laplace_vec(aa); + const Vector j = (Scalar(1.) / mu0) * (grad_div - lap); + const Vector B = curl(aa); + mom = mom + (Scalar(1.) / exp(value(lnrho))) * cross(j, B); + + mom = mom + grav_force_line(vertexIdx); + + return mom; +} +#else +Vector +momentum(in Vector uu, in Scalar lnrho, const int3 vertexIdx) { + Vector mom; + + const Matrix S = stress_tensor(uu); + + mom = -mul(gradients(uu), value(uu)) - + cs2_sound * gradient(lnrho) + + nu_visc * + (laplace_vec(uu) + Scalar(1. / 3.) * gradient_of_divergence(uu) + + Scalar(2.) * mul(S, gradient(lnrho))) + zeta * gradient_of_divergence(uu); + + mom = mom + grav_force_line(vertexIdx); + + return mom; +} +#endif + + +Vector +induction(in Vector uu, in Vector aa) { + // Note: We do (-nabla^2 A + nabla(nabla dot A)) instead of (nabla x (nabla + // x A)) in order to avoid taking the first derivative twice (did the math, + // yes this actually works. See pg.28 in arXiv:astro-ph/0109497) + // u cross B - ETA * mu0 * (mu0^-1 * [- laplace A + grad div A ]) + const Vector B = curl(aa); + const Vector grad_div = gradient_of_divergence(aa); + const Vector lap = laplace_vec(aa); + + // Note, mu0 is cancelled out + const Vector ind = cross(value(uu), B) - eta * (grad_div - lap); + + return ind; +} + + +#if LENTROPY +Scalar +lnT( in Scalar ss, in Scalar lnrho) { + const Scalar lnT = LNT0 + value(ss) / cp_sound + + (gamma - AcReal(1.)) * (value(lnrho) - LNRHO0); + return lnT; +} + +// Nabla dot (K nabla T) / (rho T) +Scalar +heat_conduction( in Scalar ss, in Scalar lnrho) { + const Scalar inv_cp_sound = AcReal(1.) / cp_sound; + + const Vector grad_ln_chi = (Vector) { + 0, + 0, + 0 + }; // TODO not used + + const Scalar first_term = gamma * inv_cp_sound * laplace(ss) + + (gamma - AcReal(1.)) * laplace(lnrho); + const Vector second_term = gamma * inv_cp_sound * gradient(ss) + + (gamma - AcReal(1.)) * gradient(lnrho); + const Vector third_term = gamma * (inv_cp_sound * gradient(ss) + + gradient(lnrho)) + grad_ln_chi; + + return cp_sound * chi * (first_term + dot(second_term, third_term)); +} + +Scalar +heating(const int i, const int j, const int k) { + return 1; +} + +Scalar +entropy(in Scalar ss, in Vector uu, in Scalar lnrho, in Vector aa) { + const Matrix S = stress_tensor(uu); + + // nabla x nabla x A / mu0 = nabla(nabla dot A) - nabla^2(A) + const Vector j = gradient_of_divergence(aa) - laplace_vec(aa); + + const Scalar inv_pT = AcReal(1.) / (exp(value(lnrho)) + exp(lnT(ss, lnrho))); + + return -dot(value(uu), gradient(ss)) + + inv_pT * (H_CONST - C_CONST + + eta * mu0 * dot(j, j) + + AcReal(2.) * exp(value(lnrho)) * nu_visc * contract(S) + + zeta * exp(value(lnrho)) * divergence(uu) * divergence(uu) + ) + heat_conduction(ss, lnrho); +} +#endif + +// Declare input and output arrays using locations specified in the +// array enum in astaroth.h +in Scalar lnrho = VTXBUF_LNRHO; +out Scalar out_lnrho = VTXBUF_LNRHO; + +in Vector uu = (int3) {VTXBUF_UUX, VTXBUF_UUY, VTXBUF_UUZ}; +out Vector out_uu = (int3) {VTXBUF_UUX,VTXBUF_UUY,VTXBUF_UUZ}; + + +#if LINDUCTION +in Vector aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +out Vector out_aa = (int3) {VTXBUF_AX,VTXBUF_AY,VTXBUF_AZ}; +#endif + +#if LENTROPY +in Scalar ss = VTXBUF_ENTROPY; +out Scalar out_ss = VTXBUF_ENTROPY; +#endif + +Kernel void +solve(Scalar dt) { + WRITE(out_lnrho, RK3(out_lnrho, lnrho, continuity(uu, lnrho), dt)); + + #if LINDUCTION + WRITE(out_aa, RK3(out_aa, aa, induction(uu, aa), dt)); + #endif + + + #if LENTROPY + WRITE(out_uu, RK3(out_uu, uu, momentum(uu, lnrho, ss, aa, vertexIdx), dt)); + WRITE(out_ss, RK3(out_ss, ss, entropy(ss, uu, lnrho, aa), dt)); + #else + WRITE(out_uu, RK3(out_uu, uu, momentum(uu, lnrho, vertexIdx), dt)); + #endif +} diff --git a/acc/samples/common_header.h b/acc/samples/common_header.h new file mode 100644 index 0000000..14eed0c --- /dev/null +++ b/acc/samples/common_header.h @@ -0,0 +1,422 @@ +/* + Copyright (C) 2014-2018, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +*/ + +/** + * @file + * \brief Brief info. + * + * Provides an interface to Astaroth. Contains all the necessary configuration + * structs and functions for running the code on multiple GPUs. + * + * All interface functions declared here (such as acInit()) operate all GPUs + * available in the node under the hood, and the user does not need any + * information about the decomposition, synchronization or such to use these + * functions. + * + */ +#pragma once + +/* Prevent name mangling */ +#ifdef __cplusplus +extern "C" { +#endif + +#include // FLT_EPSILON, etc +#include // size_t +#include // CUDA vector types (float4, etc) + + +/* + * ============================================================================= + * Flags for auto-optimization + * ============================================================================= + */ +#define AUTO_OPTIMIZE (0) // DEPRECATED TODO remove +#define BOUNDCONDS_OPTIMIZE (0) +#define GENERATE_BENCHMARK_DATA (0) + +// Device info +#define REGISTERS_PER_THREAD (255) +#define MAX_REGISTERS_PER_BLOCK (65536) +#define MAX_THREADS_PER_BLOCK (1024) +#define MAX_TB_DIM (MAX_THREADS_PER_BLOCK) +#define NUM_ITERATIONS (10) +#define WARP_SIZE (32) + + +/* + * ============================================================================= + * Compile-time constants used during simulation (user definable) + * ============================================================================= + */ +#define STENCIL_ORDER (6) + +///////////// PAD TEST +// NOTE: works only with nx is divisible by 32 +//#define PAD_LEAD (32 - STENCIL_ORDER/2) +//#define PAD_SIZE (32 - STENCIL_ORDER) +///////////// PAD TEST + +// L-prefix inherited from the old Astaroth, no idea what it means +// MV: L means a Logical switch variale, something having true of false value. +#define LFORCING (0) // Note: forcing is disabled currently in the files generated by acc (compiler of our DSL) +#define LINDUCTION (1) +#define LENTROPY (1) +#define LTEMPERATURE (0) + +#define AC_THERMAL_CONDUCTIVITY (AcReal(0.001)) // TODO: make an actual config parameter + +/* + * ============================================================================= + * Identifiers used to construct the parameter lists for AcMeshInfo + * (IntParamType and RealParamType) + * (user definable) + * ============================================================================= + */ +// clang-format off +#define AC_FOR_INT_PARAM_TYPES(FUNC)\ + /* cparams */\ + FUNC(AC_nx), \ + FUNC(AC_ny), \ + FUNC(AC_nz), \ + FUNC(AC_mx), \ + FUNC(AC_my), \ + FUNC(AC_mz), \ + FUNC(AC_nx_min), \ + FUNC(AC_ny_min), \ + FUNC(AC_nz_min), \ + FUNC(AC_nx_max), \ + FUNC(AC_ny_max), \ + FUNC(AC_nz_max), \ + /* Other */\ + FUNC(AC_max_steps), \ + FUNC(AC_save_steps), \ + FUNC(AC_bin_steps), \ + FUNC(AC_bc_type), \ + /* Additional */\ + FUNC(AC_mxy),\ + FUNC(AC_nxy),\ + FUNC(AC_nxyz) +#define AC_FOR_REAL_PARAM_TYPES(FUNC)\ + /* cparams */\ + FUNC(AC_dsx), \ + FUNC(AC_dsy), \ + FUNC(AC_dsz), \ + FUNC(AC_dsmin), \ + /* physical grid*/\ + FUNC(AC_xlen), \ + FUNC(AC_ylen), \ + FUNC(AC_zlen), \ + FUNC(AC_xorig), \ + FUNC(AC_yorig), \ + FUNC(AC_zorig), \ + /*Physical units*/\ + FUNC(AC_unit_density),\ + FUNC(AC_unit_velocity),\ + FUNC(AC_unit_length),\ + /* properties of gravitating star*/\ + FUNC(AC_star_pos_x),\ + FUNC(AC_star_pos_y),\ + FUNC(AC_star_pos_z),\ + FUNC(AC_M_star),\ + /* Run params */\ + FUNC(AC_cdt), \ + FUNC(AC_cdtv), \ + FUNC(AC_cdts), \ + FUNC(AC_nu_visc), \ + FUNC(AC_cs_sound), \ + FUNC(AC_eta), \ + FUNC(AC_mu0), \ + FUNC(AC_relhel), \ + FUNC(AC_cp_sound), \ + FUNC(AC_gamma), \ + FUNC(AC_cv_sound), \ + FUNC(AC_lnT0), \ + FUNC(AC_lnrho0), \ + FUNC(AC_zeta), \ + FUNC(AC_trans),\ + /* Other */\ + FUNC(AC_bin_save_t), \ + /* Initial condition params */\ + FUNC(AC_ampl_lnrho), \ + FUNC(AC_ampl_uu), \ + FUNC(AC_angl_uu), \ + FUNC(AC_lnrho_edge),\ + FUNC(AC_lnrho_out),\ + /* Additional helper params */\ + /* (deduced from other params do not set these directly!) */\ + FUNC(AC_G_CONST),\ + FUNC(AC_GM_star),\ + FUNC(AC_sq2GM_star),\ + FUNC(AC_cs2_sound), \ + FUNC(AC_inv_dsx), \ + FUNC(AC_inv_dsy), \ + FUNC(AC_inv_dsz) +// clang-format on + +/* + * ============================================================================= + * Identifiers for VertexBufferHandle + * (i.e. the arrays used to construct AcMesh) + * (user definable) + * ============================================================================= + */ +// clang-format off +#define AC_FOR_HYDRO_VTXBUF_HANDLES(FUNC)\ + FUNC(VTXBUF_LNRHO), \ + FUNC(VTXBUF_UUX), \ + FUNC(VTXBUF_UUY), \ + FUNC(VTXBUF_UUZ), \ + // FUNC(VTXBUF_DYE), + +#if LINDUCTION +#define AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC)\ + FUNC(VTXBUF_AX), \ + FUNC(VTXBUF_AY), \ + FUNC(VTXBUF_AZ), +#else +#define AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC) +#endif + +#if LENTROPY +#define AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC)\ + FUNC(VTXBUF_ENTROPY), +#else +#define AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC) +#endif + +#if LTEMPERATURE +#define AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC)\ + FUNC(VTXBUF_TEMPERATURE), +#else +#define AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC) +#endif + +#define AC_FOR_VTXBUF_HANDLES(FUNC)\ + AC_FOR_HYDRO_VTXBUF_HANDLES(FUNC)\ + AC_FOR_INDUCTION_VTXBUF_HANDLES(FUNC)\ + AC_FOR_ENTROPY_VTXBUF_HANDLES(FUNC)\ + AC_FOR_TEMPERATURE_VTXBUF_HANDLES(FUNC) +// clang-format on + +/* + * ============================================================================= + * Single/double precision switch + * ============================================================================= + */ +#if AC_DOUBLE_PRECISION == 1 +typedef double AcReal; +typedef double3 AcReal3; +#define AC_REAL_MAX (DBL_MAX) +#define AC_REAL_MIN (DBL_MIN) +#define AC_REAL_EPSILON (DBL_EPSILON) +#else +typedef float AcReal; +typedef float3 AcReal3; +#define AC_REAL_MAX (FLT_MAX) +#define AC_REAL_MIN (FLT_MIN) +#define AC_REAL_EPSILON (FLT_EPSILON) +#endif + +typedef struct { + AcReal3 row[3]; +} AcMatrix; + +/* + * ============================================================================= + * Helper macros + * ============================================================================= + */ +#define AC_GEN_ID(X) X +#define AC_GEN_STR(X) #X + +/* + * ============================================================================= + * Error codes + * ============================================================================= + */ +typedef enum { AC_SUCCESS = 0, AC_FAILURE = 1 } AcResult; + +/* + * ============================================================================= + * Reduction types + * ============================================================================= + */ +typedef enum { + RTYPE_MAX, + RTYPE_MIN, + RTYPE_RMS, + RTYPE_RMS_EXP, + NUM_REDUCTION_TYPES +} ReductionType; + +/* + * ============================================================================= + * Definitions for the enums and structs for AcMeshInfo (DO NOT TOUCH) + * ============================================================================= + */ +typedef enum { + AC_FOR_INT_PARAM_TYPES(AC_GEN_ID), + NUM_INT_PARAM_TYPES +} AcIntParam; + +typedef enum { + AC_FOR_REAL_PARAM_TYPES(AC_GEN_ID), + NUM_REAL_PARAM_TYPES +} AcRealParam; + +extern const char* intparam_names[]; // Defined in astaroth.cu +extern const char* realparam_names[]; // Defined in astaroth.cu + +typedef struct { + int int_params[NUM_INT_PARAM_TYPES]; + AcReal real_params[NUM_REAL_PARAM_TYPES]; +} AcMeshInfo; + +/* + * ============================================================================= + * Definitions for the enums and structs for AcMesh (DO NOT TOUCH) + * ============================================================================= + */ +typedef enum { + AC_FOR_VTXBUF_HANDLES(AC_GEN_ID) NUM_VTXBUF_HANDLES +} VertexBufferHandle; + +extern const char* vtxbuf_names[]; // Defined in astaroth.cu + +/* +typedef struct { + AcReal* data; +} VertexBuffer; +*/ + +// NOTE: there's no particular benefit declaring AcMesh a class, since +// a library user may already have allocated memory for the vertex_buffers. +// But then we would allocate memory again when the user wants to start +// filling the class with data. => Its better to consider AcMesh as a +// payload-only struct +typedef struct { + AcReal* vertex_buffer[NUM_VTXBUF_HANDLES]; + AcMeshInfo info; +} AcMesh; + +#define AC_VTXBUF_SIZE(mesh_info) \ + ((size_t)(mesh_info.int_params[AC_mx] * mesh_info.int_params[AC_my] * \ + mesh_info.int_params[AC_mz])) + +#define AC_VTXBUF_SIZE_BYTES(mesh_info) \ + (sizeof(AcReal) * AC_VTXBUF_SIZE(mesh_info)) + +#define AC_VTXBUF_COMPDOMAIN_SIZE(mesh_info) \ + (mesh_info.int_params[AC_nx] * mesh_info.int_params[AC_ny] * \ + mesh_info.int_params[AC_nz]) + +#define AC_VTXBUF_COMPDOMAIN_SIZE_BYTES(mesh_info) \ + (sizeof(AcReal) * AC_VTXBUF_COMPDOMAIN_SIZE(mesh_info)) + +#define AC_VTXBUF_IDX(i, j, k, mesh_info) \ + ((i) + (j)*mesh_info.int_params[AC_mx] + \ + (k)*mesh_info.int_params[AC_mx] * mesh_info.int_params[AC_my]) + +/* + * ============================================================================= + * Astaroth interface + * ============================================================================= + */ +/** Starting point of all GPU computation. Handles the allocation and +initialization of *all memory needed on all GPUs in the node*. In other words, +setups everything GPU-side so that calling any other GPU interface function +afterwards does not result in illegal memory accesses. */ +AcResult acInit(const AcMeshInfo& mesh_info); + +/** Splits the host_mesh and distributes it among the GPUs in the node */ +AcResult acLoad(const AcMesh& host_mesh); +AcResult acLoadWithOffset(const AcMesh& host_mesh, const int3& start, const int num_vertices); + +/** Does all three steps of the RK3 integration and computes the boundary +conditions when necessary. Note that the boundary conditions are not applied +after the final integration step. +The result can be fetched to CPU memory with acStore(). */ +AcResult acIntegrate(const AcReal& dt); + +/** Performs a single RK3 step without computing boundary conditions. */ +AcResult acIntegrateStep(const int& isubstep, const AcReal& dt); + +/** Applies boundary conditions on the GPU meshs and communicates the + ghost zones among GPUs if necessary */ +AcResult acBoundcondStep(void); + +/** Performs a scalar reduction on all GPUs in the node and returns the result. + */ +AcReal acReduceScal(const ReductionType& rtype, const VertexBufferHandle& a); + +/** Performs a vector reduction on all GPUs in the node and returns the result. + */ +AcReal acReduceVec(const ReductionType& rtype, const VertexBufferHandle& a, + const VertexBufferHandle& b, const VertexBufferHandle& c); + +/** Stores the mesh distributed among GPUs of the node back to a single host + * mesh */ +AcResult acStore(AcMesh* host_mesh); +AcResult acStoreWithOffset(const int3& start, const int num_vertices, AcMesh* host_mesh); + +/** Frees all GPU allocations and resets all devices in the node. Should be + * called at exit. */ +AcResult acQuit(void); + +/** Synchronizes all devices. All calls to Astaroth are asynchronous by default + unless otherwise stated. */ +AcResult acSynchronize(void); + +/* End extern "C" */ +#ifdef __cplusplus +} +#endif + +/* + * ============================================================================= + * Notes + * ============================================================================= + */ +/* +typedef enum { + VTX_BUF_LNRHO, + VTX_BUF_UUX, + VTX_BUF_UUY, + VTX_BUF_UUZ, + NUM_VERTEX_BUFFER_HANDLES +} VertexBufferHandle + +// LNRHO etc +typedef struct { + AcReal* data; +} VertexBuffer; + +// Host +typedef struct { + VertexBuffer vertex_buffers[NUM_VERTEX_BUFFER_HANDLES]; + MeshInfo info; +} Mesh; + +// Device +typedef struct { + VertexBuffer in[NUM_VERTEX_BUFFER_HANDLES]; + VertexBuffer out[NUM_VERTEX_BUFFER_HANDLES]; +} VertexBufferArray; +*/ diff --git a/acc/samples/sample_stencil_assembly.sas b/acc/samples/sample_stencil_assembly.sas new file mode 100644 index 0000000..4ddd64c --- /dev/null +++ b/acc/samples/sample_stencil_assembly.sas @@ -0,0 +1,49 @@ +// TODO comments and reformatting + +//Scalar +//dostuff(in Scalar uux) +//{ +// return uux[vertexIdx.x, vertexIdx.y, vertexIdx.z]; +//} + +// stencil_assembly.in +Preprocessed Scalar +some_exotic_stencil_computation(in Scalar uux) +{ + //#if STENCIL_ORDER == 2 + // const Scalar coefficients[] = {1, 1, 1}; + //#else if STENCIL_ORDER == 4 + // const Scalar coefficients[] = {....}; + //#endif + + int i = vertexIdx.x; + int j = vertexIdx.y; + int k = vertexIdx.z; + const Scalar coefficients[] = {1, 2, 3}; + + return coefficients[0] * uux[i-1, j, k] + + coefficients[1] * uux[i, j, k] + + coefficients[2] * uux[i+1, j, k]; +} + +// stencil_process.in +//in Scalar uux_in = VTXBUF_UUX; +//out Scalar uux_out = VTXBUF_UUX; + + +//Kernel +//solve(Scalar dt) +//{ +// uux_out = some_exotic_stencil(uux_in); +//} + + + + + + + + + + + diff --git a/acc/samples/sample_stencil_process.sps b/acc/samples/sample_stencil_process.sps new file mode 100644 index 0000000..219e40e --- /dev/null +++ b/acc/samples/sample_stencil_process.sps @@ -0,0 +1,149 @@ +// TODO comments and reformatting + +uniform Scalar dsx; +uniform Scalar dsy; +uniform Scalar dsz; + +uniform Scalar GM_star; +// Other uniforms types than Scalar or int not yet supported + +// BUILTIN +//Scalar dot(...){} + +// BUILTIN +//Scalar distance(Vector a, Vector b) { return sqrt(dot(a, b)); } + +// BUILTIN +// Scalar first_derivative(Scalar pencil[], Scalar inv_ds) { return pencil[3] * inv_ds; } + +Scalar first_derivative(Scalar pencil[], Scalar inv_ds) +{ + Scalar res = 0; + for (int i = 0; i < STENCIL_ORDER+1; ++i) { + res = res + pencil[i]; + } + return inv_ds * res; +} + +Scalar distance(Vector a, Vector b) +{ + return sqrt(a.x * b.x + a.y * b.y + a.z * b.z); +} + +Scalar +gravity_potential(int i, int j, int k) +{ + Vector star_pos = (Vector){0, 0, 0}; + Vector vertex_pos = (Vector){dsx * i, dsy * j, dsz * k}; + return GM_star / distance(star_pos, vertex_pos); +} + +Scalar +gradx_gravity_potential(int i, int j, int k) +{ + Scalar pencil[STENCIL_ORDER + 1]; + for (int offset = -STENCIL_ORDER; offset <= STENCIL_ORDER; ++offset) { + pencil[offset+STENCIL_ORDER] = gravity_potential(i + offset, j, k); + } + + Scalar inv_ds = Scalar(1.) / dsx; + return first_derivative(pencil, inv_ds); +} + +Scalar +grady_gravity_potential(int i, int j, int k) +{ + Scalar pencil[STENCIL_ORDER + 1]; + for (int offset = -STENCIL_ORDER; offset <= STENCIL_ORDER; ++offset) { + pencil[offset+STENCIL_ORDER] = gravity_potential(i, j + offset, k); + } + + Scalar inv_ds = Scalar(1.) / dsy; + return first_derivative(pencil, inv_ds); +} + +Scalar +gradz_gravity_potential(int i, int j, int k) +{ + Scalar pencil[STENCIL_ORDER + 1]; + for (int offset = -STENCIL_ORDER; offset <= STENCIL_ORDER; ++offset) { + pencil[offset+STENCIL_ORDER] = gravity_potential(i, j, k + offset); + } + + Scalar inv_ds = Scalar(1.) / dsz; + return first_derivative(pencil, inv_ds); +} + +Vector +momentum(int i, int j, int k, in Vector uu) +{ + + Vector gravity_potential = (Vector){gradx_gravity_potential(i, j, k), + grady_gravity_potential(i, j, k), + gradz_gravity_potential(i, j, k)}; + + + return gravity_potential; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/acc/src/acc.l b/acc/src/acc.l new file mode 100644 index 0000000..e68fe8b --- /dev/null +++ b/acc/src/acc.l @@ -0,0 +1,56 @@ +%option yylineno + +D [0-9] +L [a-zA-Z_] + +%{ +#include "acc.tab.h" +%} + +%% + +"Scalar" { return SCALAR; } /* Builtin types */ +"Vector" { return VECTOR; } +"Matrix" { return MATRIX; } +"void" { return VOID; } /* Rest of the types inherited from C */ +"int" { return INT; } +"int3" { return INT3; } + +"Kernel" { return KERNEL; } /* Function specifiers */ +"Preprocessed" { return PREPROCESSED; } + +"const" { return CONSTANT; } +"in" { return IN; } /* Device func storage specifiers */ +"out" { return OUT; } +"uniform" { return UNIFORM; } + +"else if" { return ELIF; } +"if" { return IF; } +"else" { return ELSE; } +"for" { return FOR; } +"while" { return WHILE; } + +"return" { return RETURN; } + +{D}+"."?{D}*[flud]? { return NUMBER; } /* Literals */ +"."{D}+[flud]? { return NUMBER; } +{L}({L}|{D})* { return IDENTIFIER; } +\"(.)*\" { return IDENTIFIER; } /* String */ + +"==" { return LEQU; }/* Logic operations */ +"&&" { return LAND; } +"||" { return LOR; } +"<=" { return LLEQU; } + +"++" { return INPLACE_INC; } +"--" { return INPLACE_DEC; } + +[-+*/;=\[\]{}(),\.<>] { return yytext[0]; } /* Characters */ + + +"//".* { /* Skip regular comments */ } +[ \t\n\v\r]+ { /* Ignore whitespace, tabs and newlines */ } +. { printf("unrecognized char %d: [%c]\n", *yytext, *yytext); } + + +%% diff --git a/acc/src/acc.y b/acc/src/acc.y new file mode 100644 index 0000000..db49225 --- /dev/null +++ b/acc/src/acc.y @@ -0,0 +1,234 @@ +%{ +#include +#include + +#include "ast.h" + +extern char* yytext; + +int yylex(); +int yyerror(const char* str); +int yyget_lineno(); + +#define YYSTYPE ASTNode* // Sets the default type +%} + +%token CONSTANT IN OUT UNIFORM +%token IDENTIFIER NUMBER +%token RETURN +%token SCALAR VECTOR MATRIX +%token VOID INT INT3 +%token IF ELSE FOR WHILE ELIF +%token LEQU LAND LOR LLEQU +%token KERNEL PREPROCESSED +%token INPLACE_INC INPLACE_DEC + +%% + +root: program { root->lhs = $1; } + ; + +program: /* Empty*/ { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); } + | program function_definition { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + | program assignment ';' /* Global definition */ { $$ = astnode_create(NODE_UNKNOWN, $1, $2); $$->postfix = ';'; } + | program declaration ';' /* Global declaration */ { $$ = astnode_create(NODE_UNKNOWN, $1, $2); $$->postfix = ';'; } + ; + +/* + * ============================================================================= + * Functions + * ============================================================================= + */ + +function_definition: function_declaration compound_statement { $$ = astnode_create(NODE_FUNCTION_DEFINITION, $1, $2); } + ; + +function_declaration: declaration function_parameter_declaration { $$ = astnode_create(NODE_FUNCTION_DECLARATION, $1, $2); } + ; + +function_parameter_declaration: '(' ')' { $$ = astnode_create(NODE_FUNCTION_PARAMETER_DECLARATION, NULL, NULL); $$->prefix = '('; $$->postfix = ')'; } + | '(' declaration_list ')' { $$ = astnode_create(NODE_FUNCTION_PARAMETER_DECLARATION, $2, NULL); $$->prefix = '('; $$->postfix = ')'; } + ; + +/* + * ============================================================================= + * Statement + * ============================================================================= + */ +statement_list: statement { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | statement_list statement { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + ; + +compound_statement: '{' '}' { $$ = astnode_create(NODE_COMPOUND_STATEMENT, NULL, NULL); $$->prefix = '{'; $$->postfix = '}'; } + | '{' statement_list '}' { $$ = astnode_create(NODE_COMPOUND_STATEMENT, $2, NULL); $$->prefix = '{'; $$->postfix = '}'; } + ; + +statement: selection_statement { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | iteration_statement { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | exec_statement ';' { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); $$->postfix = ';'; } + ; + +selection_statement: IF expression else_selection_statement { $$ = astnode_create(NODE_UNKNOWN, $2, $3); $$->prefix = IF; } + ; + +else_selection_statement: compound_statement { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | compound_statement elif_selection_statement { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + | compound_statement ELSE compound_statement { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = ELSE; } + ; + +elif_selection_statement: ELIF expression else_selection_statement { $$ = astnode_create(NODE_UNKNOWN, $2, $3); $$->prefix = ELIF; } + ; + +iteration_statement: WHILE expression compound_statement { $$ = astnode_create(NODE_UNKNOWN, $2, $3); $$->prefix = WHILE; } + | FOR for_expression compound_statement { $$ = astnode_create(NODE_UNKNOWN, $2, $3); $$->prefix = FOR; } + ; + +for_expression: '(' for_init_param for_other_params ')' { $$ = astnode_create(NODE_UNKNOWN, $2, $3); $$->prefix = '('; $$->postfix = ')'; } + ; + +for_init_param: expression ';' { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); $$->postfix = ';'; } + | assignment ';' { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); $$->postfix = ';'; } + ; + +for_other_params: expression ';' { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); $$->postfix = ';'; } + | expression ';' expression { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = ';'; } + ; + +exec_statement: declaration { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | assignment { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | expression { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | return return_statement { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + ; + +assignment: declaration '=' expression { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = '='; } + | expression '=' expression { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = '='; } + ; + +return_statement: /* Empty */ { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); } + | expression { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + ; + +/* + * ============================================================================= + * Declaration + * ============================================================================= + */ + +declaration_list: declaration { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | declaration_list ',' declaration { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = ','; } + ; + +declaration: type_declaration identifier { $$ = astnode_create(NODE_DECLARATION, $1, $2); } // Note: accepts only one type qualifier. Good or not? + | type_declaration array_declaration { $$ = astnode_create(NODE_DECLARATION, $1, $2); } + ; + +array_declaration: identifier '[' ']' { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); $$->infix = '['; $$->postfix = ']'; } + | identifier '[' expression ']' { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = '['; $$->postfix = ']'; } + ; + +type_declaration: type_specifier { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | type_qualifier type_specifier { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + ; + +/* + * ============================================================================= + * Expressions + * ============================================================================= + */ +expression_list: expression { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | expression_list ',' expression { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = ','; } + ; + +expression: unary_expression { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | expression binary_expression { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + ; + +binary_expression: binary_operator unary_expression { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + ; + +unary_expression: postfix_expression { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | unary_operator postfix_expression { $$ = astnode_create(NODE_UNKNOWN, $1, $2); } + ; + +postfix_expression: primary_expression { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | postfix_expression '[' expression_list ']' /* Subscript */ { $$ = astnode_create(NODE_MULTIDIM_SUBSCRIPT_EXPRESSION, $1, $3); $$->infix = '['; $$->postfix = ']'; } + | cast_expression '{' expression_list '}' /* Array */ { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = '{'; $$->postfix = '}'; } + | postfix_expression '(' ')' /* Function call */ { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); $$->infix = '('; $$->postfix = ')'; } + | postfix_expression '(' expression_list ')' /* Function call */ { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = '('; $$->postfix = ')'; } + | type_specifier '(' expression_list ')' /* Cast */ { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = '('; $$->postfix = ')'; } + | postfix_expression '.' identifier /* Member access */ { $$ = astnode_create(NODE_UNKNOWN, $1, $3); $$->infix = '.'; } + ; + +cast_expression: /* Empty: implicit cast */ { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); } + | '(' type_specifier ')' { $$ = astnode_create(NODE_UNKNOWN, $2, NULL); $$->prefix = '('; $$->postfix = ')'; } + ; + +primary_expression: identifier { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | number { $$ = astnode_create(NODE_UNKNOWN, $1, NULL); } + | '(' expression ')' { $$ = astnode_create(NODE_UNKNOWN, $2, NULL); $$->prefix = '('; $$->postfix = ')'; } + ; + + + +/* + * ============================================================================= + * Terminals + * ============================================================================= + */ + +binary_operator: '+' { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | '-' { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | '/' { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | '*' { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | '<' { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | '>' { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | LEQU { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); astnode_set_buffer(yytext, $$); } + | LAND { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); astnode_set_buffer(yytext, $$); } + | LOR { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); astnode_set_buffer(yytext, $$); } + | LLEQU { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); astnode_set_buffer(yytext, $$); } + ; + +unary_operator: '-' /* C-style casts are disallowed, would otherwise be defined here */ { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | '!' { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->infix = yytext[0]; } + | INPLACE_INC { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->token = INPLACE_INC; } + | INPLACE_DEC { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); $$->token = INPLACE_DEC; } + ; + +type_qualifier: KERNEL { $$ = astnode_create(NODE_TYPE_QUALIFIER, NULL, NULL); $$->token = KERNEL; } + | PREPROCESSED { $$ = astnode_create(NODE_TYPE_QUALIFIER, NULL, NULL); $$->token = PREPROCESSED; } + | CONSTANT { $$ = astnode_create(NODE_TYPE_QUALIFIER, NULL, NULL); $$->token = CONSTANT; } + | IN { $$ = astnode_create(NODE_TYPE_QUALIFIER, NULL, NULL); $$->token = IN; } + | OUT { $$ = astnode_create(NODE_TYPE_QUALIFIER, NULL, NULL); $$->token = OUT; } + | UNIFORM { $$ = astnode_create(NODE_TYPE_QUALIFIER, NULL, NULL); $$->token = UNIFORM; } + ; + +type_specifier: VOID { $$ = astnode_create(NODE_TYPE_SPECIFIER, NULL, NULL); $$->token = VOID; } + | INT { $$ = astnode_create(NODE_TYPE_SPECIFIER, NULL, NULL); $$->token = INT; } + | INT3 { $$ = astnode_create(NODE_TYPE_SPECIFIER, NULL, NULL); $$->token = INT3; } + | SCALAR { $$ = astnode_create(NODE_TYPE_SPECIFIER, NULL, NULL); $$->token = SCALAR; } + | VECTOR { $$ = astnode_create(NODE_TYPE_SPECIFIER, NULL, NULL); $$->token = VECTOR; } + | MATRIX { $$ = astnode_create(NODE_TYPE_SPECIFIER, NULL, NULL); $$->token = MATRIX; } + ; + +identifier: IDENTIFIER { $$ = astnode_create(NODE_IDENTIFIER, NULL, NULL); astnode_set_buffer(yytext, $$); } + ; + +number: NUMBER { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); astnode_set_buffer(yytext, $$); } + ; + +return: RETURN { $$ = astnode_create(NODE_UNKNOWN, NULL, NULL); astnode_set_buffer(yytext, $$); } + ; + +%% + +void +print(void) +{ + printf("%s\n", yytext); +} + +int +yyerror(const char* str) +{ + fprintf(stderr, "%s on line %d when processing char %d: [%s]\n", str, yyget_lineno(), *yytext, yytext); +} diff --git a/acc/src/ast.h b/acc/src/ast.h new file mode 100644 index 0000000..830a8c1 --- /dev/null +++ b/acc/src/ast.h @@ -0,0 +1,126 @@ +/* + Nodes for the Abstract Syntax Tree + + Statement: syntactic unit tha expresses some action. + May have internal components, expressions, which are evaluated + + Statements: return value + block +*/ +#include +#include + +#define BUFFER_SIZE (4096) + +#define GEN_ID(X) X +#define GEN_STR(X) #X + +#define FOR_NODE_TYPES(FUNC) \ + FUNC(NODE_UNKNOWN), \ + FUNC(NODE_DEFINITION), \ + FUNC(NODE_GLOBAL_DEFINITION), \ + FUNC(NODE_DECLARATION), \ + FUNC(NODE_TYPE_QUALIFIER), \ + FUNC(NODE_TYPE_SPECIFIER), \ + FUNC(NODE_IDENTIFIER), \ + FUNC(NODE_FUNCTION_DEFINITION), \ + FUNC(NODE_FUNCTION_DECLARATION), \ + FUNC(NODE_COMPOUND_STATEMENT), \ + FUNC(NODE_FUNCTION_PARAMETER_DECLARATION), \ + FUNC(NODE_MULTIDIM_SUBSCRIPT_EXPRESSION) + +/* +// Recreating strdup is not needed when using the GNU compiler. +// Let's also just say that anything but the GNU +// compiler is NOT supported, since there are also +// some gcc-specific calls in the files generated +// by flex and being completely compiler-independent is +// not a priority right now +#ifndef strdup +static inline char* +strdup(const char* in) +{ + const size_t len = strlen(in) + 1; + char* out = malloc(len); + + if (out) { + memcpy(out, in, len); + return out; + } else { + return NULL; + } +} +#endif +*/ + +typedef enum { + FOR_NODE_TYPES(GEN_ID), + NUM_NODE_TYPES +} NodeType; + +typedef struct astnode_s { + int id; + struct astnode_s* lhs; + struct astnode_s* rhs; + NodeType type; // Type of the AST node + char* buffer; // Indentifiers and other strings (empty by default) + + int token; // Type of a terminal (that is not a simple char) + int prefix; // Tokens. Also makes the grammar since we don't have + int infix; // to divide it into max two-child rules + int postfix; // (which makes it much harder to read) +} ASTNode; + + +static inline ASTNode* +astnode_create(const NodeType type, ASTNode* lhs, ASTNode* rhs) +{ + ASTNode* node = malloc(sizeof(node[0])); + + static int id_counter = 0; + node->id = id_counter++; + node->type = type; + node->lhs = lhs; + node->rhs = rhs; + node->buffer = NULL; + + node->prefix = node->infix = node->postfix = 0; + + return node; +} + +static inline void +astnode_set_buffer(const char* buffer, ASTNode* node) +{ + node->buffer = strdup(buffer); +} + +static inline void +astnode_destroy(ASTNode* node) +{ + if (node->lhs) + astnode_destroy(node->lhs); + if (node->rhs) + astnode_destroy(node->rhs); + if (node->buffer) + free(node->buffer); + free(node); +} + + +extern ASTNode* root; + +/* +typedef enum { + SCOPE_BLOCK +} ScopeType; + +typedef struct symbol_s { + int type_specifier; + char* identifier; + int scope; + struct symbol_s* next; +} Symbol; + +extern ASTNode* symbol_table; +*/ diff --git a/acc/src/code_generator.c b/acc/src/code_generator.c new file mode 100644 index 0000000..66d4c9d --- /dev/null +++ b/acc/src/code_generator.c @@ -0,0 +1,569 @@ +/* + Copyright (C) 2014-2018, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +*/ + +/** + * @file + * \brief Brief info. + * + * Detailed info. + * + */ + +#include +#include +#include +#include + +#include "acc.tab.h" +#include "ast.h" + +ASTNode* root = NULL; + +static const char inout_name_prefix[] = "handle_"; +static bool doing_stencil_assembly = true; + +/* + * ============================================================================= + * Translation + * ============================================================================= + */ +#define TRANSLATION_TABLE_SIZE (1024) +static const char* translation_table[TRANSLATION_TABLE_SIZE] = { + [0] = NULL, + // Control flow + [IF] = "if", + [ELSE] = "else", + [ELIF] = "else if", + [WHILE] = "while", + [FOR] = "for", + // Type specifiers + [VOID] = "void", + [INT] = "int", + [INT3] = "int3", + [SCALAR] = "AcReal", + [VECTOR] = "AcReal3", + [MATRIX] = "AcMatrix", + // Type qualifiers + [KERNEL] = "template static " + "__global__", //__launch_bounds__(RK_THREADBLOCK_SIZE, + // RK_LAUNCH_BOUND_MIN_BLOCKS), + [PREPROCESSED] = "static __device__ " + "__forceinline__", + [CONSTANT] = "const", + [IN] = "in", + [OUT] = "out", + [UNIFORM] = "uniform", + // ETC + [INPLACE_INC] = "++", + [INPLACE_DEC] = "--", + // Unary + [','] = ",", + [';'] = ";\n", + ['('] = "(", + [')'] = ")", + ['['] = "[", + [']'] = "]", + ['{'] = "{\n", + ['}'] = "}\n", + ['='] = "=", + ['+'] = "+", + ['-'] = "-", + ['/'] = "/", + ['*'] = "*", + ['<'] = "<", + ['>'] = ">", + ['!'] = "!", + ['.'] = "."}; + +static const char* +translate(const int token) +{ + assert(token >= 0); + assert(token < TRANSLATION_TABLE_SIZE); + if (token > 0) { + if (!translation_table[token]) + printf("ERROR: unidentified token %d\n", token); + assert(translation_table[token]); + } + + return translation_table[token]; +} + +/* + * ============================================================================= + * Symbols + * ============================================================================= + */ +typedef enum { + SYMBOLTYPE_FUNCTION, + SYMBOLTYPE_FUNCTION_PARAMETER, + SYMBOLTYPE_OTHER, + NUM_SYMBOLTYPES +} SymbolType; + +#define MAX_ID_LEN (128) +typedef struct { + SymbolType type; + int type_qualifier; + int type_specifier; + char identifier[MAX_ID_LEN]; +} Symbol; + +#define SYMBOL_TABLE_SIZE (4096) +static Symbol symbol_table[SYMBOL_TABLE_SIZE] = {}; +static int num_symbols = 0; + +static int +symboltable_lookup(const char* identifier) +{ + if (!identifier) + return -1; + + for (int i = 0; i < num_symbols; ++i) + if (strcmp(identifier, symbol_table[i].identifier) == 0) + return i; + + return -1; +} + +static void +add_symbol(const SymbolType type, const int tqualifier, const int tspecifier, const char* id) +{ + assert(num_symbols < SYMBOL_TABLE_SIZE); + + symbol_table[num_symbols].type = type; + symbol_table[num_symbols].type_qualifier = tqualifier; + symbol_table[num_symbols].type_specifier = tspecifier; + strcpy(symbol_table[num_symbols].identifier, id); + + ++num_symbols; +} + +static void +rm_symbol(const int handle) +{ + assert(handle >= 0 && handle < num_symbols); + + if (&symbol_table[handle] != &symbol_table[num_symbols - 1]) + memcpy(&symbol_table[handle], &symbol_table[num_symbols - 1], sizeof(Symbol)); + --num_symbols; +} + +static void +print_symbol(const int handle) +{ + assert(handle < SYMBOL_TABLE_SIZE); + + const char* fields[] = {translate(symbol_table[handle].type_qualifier), + translate(symbol_table[handle].type_specifier), + symbol_table[handle].identifier}; + const size_t num_fields = sizeof(fields) / sizeof(fields[0]); + + for (int i = 0; i < num_fields; ++i) + if (fields[i]) + printf("%s ", fields[i]); +} + +static void +translate_latest_symbol(void) +{ + const int handle = num_symbols - 1; + assert(handle < SYMBOL_TABLE_SIZE); + + Symbol* symbol = &symbol_table[handle]; + + // FUNCTION + if (symbol->type == SYMBOLTYPE_FUNCTION) { + // KERNEL FUNCTION + if (symbol->type_qualifier == KERNEL) { + printf("%s %s\n%s", translate(symbol->type_qualifier), + translate(symbol->type_specifier), symbol->identifier); + } + // PREPROCESSED FUNCTION + else if (symbol->type_qualifier == PREPROCESSED) { + printf("%s %s\npreprocessed_%s", translate(symbol->type_qualifier), + translate(symbol->type_specifier), symbol->identifier); + } + // OTHER FUNCTION + else { + const char* regular_function_decorator = "static __device__ " + "__forceinline__"; + printf("%s %s %s\n%s", regular_function_decorator, + translate(symbol->type_qualifier) ? translate(symbol->type_qualifier) : "", + translate(symbol->type_specifier), symbol->identifier); + } + } + // FUNCTION PARAMETER + else if (symbol->type == SYMBOLTYPE_FUNCTION_PARAMETER) { + if (symbol->type_qualifier == IN || symbol->type_qualifier == OUT) { + if (doing_stencil_assembly) + printf("const __restrict__ %s* %s", translate(symbol->type_specifier), + symbol->identifier); + else + printf("const %sData& %s", translate(symbol->type_specifier), symbol->identifier); + } + else { + print_symbol(handle); + } + } + // UNIFORM + else if (symbol->type_qualifier == UNIFORM) { + /* Do nothing */ + } + // IN / OUT + else if (symbol->type != SYMBOLTYPE_FUNCTION_PARAMETER && + (symbol->type_qualifier == IN || symbol->type_qualifier == OUT)) { + const char* inout_type_qualifier = "static __device__ const auto"; + printf("%s %s%s", inout_type_qualifier, inout_name_prefix, symbol_table[handle].identifier); + } + // OTHER + else { + print_symbol(handle); + } +} + +static void +print_symbol_table(void) +{ + for (int i = 0; i < num_symbols; ++i) { + printf("%d: ", i); + const char* fields[] = {translate(symbol_table[i].type_qualifier), + translate(symbol_table[i].type_specifier), + symbol_table[i].identifier}; + const size_t num_fields = sizeof(fields) / sizeof(fields[0]); + + for (int i = 0; i < num_fields; ++i) + if (fields[i]) + printf("%s ", fields[i]); + + if (symbol_table[i].type == SYMBOLTYPE_FUNCTION) + printf("(function)"); + else if (symbol_table[i].type == SYMBOLTYPE_FUNCTION_PARAMETER) + printf("(function parameter)"); + else + printf("(other)"); + printf("\n"); + } +} + +/* + * ============================================================================= + * State + * ============================================================================= + */ +static bool inside_declaration = false; +static bool inside_function_declaration = false; +static bool inside_function_parameter_declaration = false; + +static bool inside_kernel = false; +static bool inside_preprocessed = false; + +static int scope_start = 0; + +/* + * ============================================================================= + * AST traversal + * ============================================================================= + */ + +static void +traverse(const ASTNode* node) +{ + // Prefix logic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (node->type == NODE_FUNCTION_DECLARATION) + inside_function_declaration = true; + if (node->type == NODE_FUNCTION_PARAMETER_DECLARATION) + inside_function_parameter_declaration = true; + if (node->type == NODE_DECLARATION) + inside_declaration = true; + + if (!inside_declaration && translate(node->prefix)) + printf("%s", translate(node->prefix)); + + // BOILERPLATE START//////////////////////////////////////////////////////// + if (node->type == NODE_TYPE_QUALIFIER && node->token == KERNEL) + inside_kernel = true; + + // Kernel parameter boilerplate + const char* kernel_parameter_boilerplate = "GEN_KERNEL_PARAM_BOILERPLATE, "; + if (inside_kernel && node->type == NODE_FUNCTION_PARAMETER_DECLARATION) + printf("%s ", kernel_parameter_boilerplate); + + // Kernel builtin variables boilerplate (read input/output arrays and setup + // indices) + const char* kernel_builtin_variables_boilerplate = "GEN_KERNEL_BUILTIN_VARIABLES_" + "BOILERPLATE();"; + if (inside_kernel && node->type == NODE_COMPOUND_STATEMENT) { + printf("%s ", kernel_builtin_variables_boilerplate); + + for (int i = 0; i < num_symbols; ++i) { + if (symbol_table[i].type_qualifier == IN) { + printf("const %sData %s = READ(%s%s);\n", translate(symbol_table[i].type_specifier), + symbol_table[i].identifier, inout_name_prefix, symbol_table[i].identifier); + } else if (symbol_table[i].type_qualifier == OUT) { + printf("%s %s = READ_OUT(%s%s);", translate(symbol_table[i].type_specifier), symbol_table[i].identifier, inout_name_prefix, symbol_table[i].identifier); + //printf("%s %s = buffer.out[%s%s][IDX(vertexIdx.x, vertexIdx.y, vertexIdx.z)];\n", translate(symbol_table[i].type_specifier), symbol_table[i].identifier, inout_name_prefix, symbol_table[i].identifier); + } + } + } + + // Preprocessed parameter boilerplate + if (node->type == NODE_TYPE_QUALIFIER && node->token == PREPROCESSED) + inside_preprocessed = true; + static const char + preprocessed_parameter_boilerplate[] = "const int3 vertexIdx, "; + if (inside_preprocessed && node->type == NODE_FUNCTION_PARAMETER_DECLARATION) + printf("%s ", preprocessed_parameter_boilerplate); + // BOILERPLATE END//////////////////////////////////////////////////////// + + // Enter LHS + if (node->lhs) + traverse(node->lhs); + + // Infix logic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (!inside_declaration && translate(node->infix)) + printf("%s ", translate(node->infix)); + + if (node->type == NODE_FUNCTION_DECLARATION) + inside_function_declaration = false; + + + // If the node is a subscript expression and the expression list inside it is not empty + if (node->type == NODE_MULTIDIM_SUBSCRIPT_EXPRESSION && node->rhs) + printf("IDX("); + + // Do a regular translation + if (!inside_declaration) { + const int handle = symboltable_lookup(node->buffer); + if (handle >= 0) { // The variable exists in the symbol table + const Symbol* symbol = &symbol_table[handle]; + + //if (symbol->type_qualifier == OUT) { + // printf("%s%s", inout_name_prefix, symbol->identifier); + //} + if (symbol->type_qualifier == UNIFORM) { + if (symbol->type_specifier == SCALAR) + printf("DCONST_REAL(AC_%s) ", symbol->identifier); + else if (symbol->type_specifier == INT) + printf("DCONST_INT(AC_%s) ", symbol->identifier); + else + printf("INVALID UNIFORM type specifier %s with %s\n", + translate(symbol->type_specifier), symbol->identifier); + } + else { + // Do a regular translation + if (translate(node->token)) + printf("%s ", translate(node->token)); + if (node->buffer) + printf("%s ", node->buffer); + } + } + else { + // Do a regular translation + if (translate(node->token)) + printf("%s ", translate(node->token)); + if (node->buffer) + printf("%s ", node->buffer); + } + } + + if (node->type == NODE_FUNCTION_DECLARATION) { + scope_start = num_symbols; + } + + // Enter RHS + if (node->rhs) + traverse(node->rhs); + + // Postfix logic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + // If the node is a subscript expression and the expression list inside it is not empty + if (node->type == NODE_MULTIDIM_SUBSCRIPT_EXPRESSION && node->rhs) + printf(")"); // Closing bracket of IDX() + + // Generate writeback boilerplate for OUT fields + if (inside_kernel && node->type == NODE_COMPOUND_STATEMENT) { + for (int i = 0; i < num_symbols; ++i) { + if (symbol_table[i].type_qualifier == OUT) { + printf("WRITE_OUT(%s%s, %s);\n", inout_name_prefix, symbol_table[i].identifier, symbol_table[i].identifier); + //printf("buffer.out[%s%s][IDX(vertexIdx.x, vertexIdx.y, vertexIdx.z)] = %s;\n", inout_name_prefix, symbol_table[i].identifier, symbol_table[i].identifier); + } + } + } + + if (!inside_declaration && translate(node->postfix)) + printf("%s", translate(node->postfix)); + + if (node->type == NODE_DECLARATION) { + inside_declaration = false; + + int tqual = 0; + int tspec = 0; + if (node->lhs && node->lhs->lhs) { + if (node->lhs->lhs->type == NODE_TYPE_QUALIFIER) + tqual = node->lhs->lhs->token; + else if (node->lhs->lhs->type == NODE_TYPE_SPECIFIER) + tspec = node->lhs->lhs->token; + } + if (node->lhs && node->lhs->rhs) { + if (node->lhs->rhs->type == NODE_TYPE_SPECIFIER) + tspec = node->lhs->rhs->token; + } + + // Determine symbol type + SymbolType symboltype = SYMBOLTYPE_OTHER; + if (inside_function_declaration) + symboltype = SYMBOLTYPE_FUNCTION; + else if (inside_function_parameter_declaration) + symboltype = SYMBOLTYPE_FUNCTION_PARAMETER; + + // Determine identifier + if (node->rhs->type == NODE_IDENTIFIER) { + add_symbol(symboltype, tqual, tspec, node->rhs->buffer); // Ordinary + translate_latest_symbol(); + } + else { + add_symbol(symboltype, tqual, tspec, + node->rhs->lhs->buffer); // Array + translate_latest_symbol(); + // Traverse the expression once again, this time with + // "inside_declaration" flag off + printf("%s ", translate(node->rhs->infix)); + if (node->rhs->rhs) + traverse(node->rhs->rhs); + printf("%s ", translate(node->rhs->postfix)); + } + } + + if (node->type == NODE_FUNCTION_PARAMETER_DECLARATION) + inside_function_parameter_declaration = false; + + if (node->type == NODE_FUNCTION_DEFINITION) { + while (num_symbols > scope_start) + rm_symbol(num_symbols - 1); + + inside_kernel = false; + inside_preprocessed = false; + } +} + +// TODO: these should use the generic type names SCALAR and VECTOR +static void +generate_preprocessed_structures(void) +{ + // PREPROCESSED DATA STRUCT + printf("\n"); + printf("typedef struct {\n"); + for (int i = 0; i < num_symbols; ++i) { + if (symbol_table[i].type_qualifier == PREPROCESSED) + printf("%s %s;\n", translate(symbol_table[i].type_specifier), + symbol_table[i].identifier); + } + printf("} %sData;\n", translate(SCALAR)); + + // FILLING THE DATA STRUCT + printf("static __device__ __forceinline__ AcRealData\ + read_data(const int3 vertexIdx,\ + AcReal* __restrict__ buf[], const int handle)\ + {\n\ + %sData data;\n", + translate(SCALAR)); + + for (int i = 0; i < num_symbols; ++i) { + if (symbol_table[i].type_qualifier == PREPROCESSED) + printf("data.%s = preprocessed_%s(vertexIdx, buf[handle]);\n", symbol_table[i].identifier, + symbol_table[i].identifier); + } + printf("return data;\n"); + printf("}\n"); + + // FUNCTIONS FOR ACCESSING MEMBERS OF THE PREPROCESSED STRUCT + for (int i = 0; i < num_symbols; ++i) { + if (symbol_table[i].type_qualifier == PREPROCESSED) + printf("static __device__ __forceinline__ %s\ + %s(const AcRealData& data)\ + {\n\ + return data.%s;\ + }\n", + translate(symbol_table[i].type_specifier), symbol_table[i].identifier, + symbol_table[i].identifier); + } + + // Syntactic sugar: generate also a Vector data struct + printf("\ + typedef struct {\ + AcRealData x;\ + AcRealData y;\ + AcRealData z;\ + } AcReal3Data;\ + \ + static __device__ __forceinline__ AcReal3Data\ + read_data(const int3 vertexIdx,\ + AcReal* __restrict__ buf[], const int3& handle)\ + {\ + AcReal3Data data;\ + \ + data.x = read_data(vertexIdx, buf, handle.x);\ + data.y = read_data(vertexIdx, buf, handle.y);\ + data.z = read_data(vertexIdx, buf, handle.z);\ + \ + return data;\ + }\ + "); +} + +int +main(int argc, char** argv) +{ + if (argc == 2) { + if (!strcmp(argv[1], "-sas")) + doing_stencil_assembly = true; + else if (!strcmp(argv[1], "-sps")) + doing_stencil_assembly = false; + else + printf("Unknown flag %s. Generating stencil assembly.\n", argv[1]); + } + else { + printf("Usage: ./acc [flags]\n" + "Flags:\n" + "\t-sas - Generates code for the stencil assembly stage\n" + "\t-sps - Generates code for the stencil processing " + "stage\n"); + printf("\n"); + return EXIT_FAILURE; + } + + root = astnode_create(NODE_UNKNOWN, NULL, NULL); + + const int retval = yyparse(); + if (retval) { + printf("COMPILATION FAILED\n"); + return EXIT_FAILURE; + } + + // Traverse + traverse(root); + if (doing_stencil_assembly) + generate_preprocessed_structures(); + + // print_symbol_table(); + + // Cleanup + astnode_destroy(root); + // printf("COMPILATION SUCCESS\n"); +} diff --git a/acc/test_grammar.sh b/acc/test_grammar.sh new file mode 100755 index 0000000..ee579de --- /dev/null +++ b/acc/test_grammar.sh @@ -0,0 +1,48 @@ +#!/bin/bash +cd `dirname $0` # Only operate in the same directory with this script + +./build_acc.sh + +mkdir -p testbin +./compile.sh samples/sample_stencil_process.sps +./compile.sh samples/sample_stencil_assembly.sas + +mv stencil_process.cuh testbin/ +mv stencil_assembly.cuh testbin/ + +printf " +#include +#include +#include \"%s\" // i.e. astaroth.h + +__constant__ AcMeshInfo d_mesh_info; +#define DCONST_INT(X) (d_mesh_info.int_params[X]) +#define DCONST_REAL(X) (d_mesh_info.real_params[X]) +#define DEVICE_VTXBUF_IDX(i, j, k) ((i) + (j)*DCONST_INT(AC_mx) + (k)*DCONST_INT(AC_mxy)) + + +static __device__ __forceinline__ int +IDX(const int i) +{ + return i; +} + +static __device__ __forceinline__ int +IDX(const int i, const int j, const int k) +{ + return DEVICE_VTXBUF_IDX(i, j, k); +} + +static __device__ __forceinline__ int +IDX(const int3 idx) +{ + return DEVICE_VTXBUF_IDX(idx.x, idx.y, idx.z); +} + +#include \"%s\" +#include \"%s\" +int main(void) { printf(\"Grammar check complete.\\\nAll tests passed.\\\n\"); return EXIT_SUCCESS; } +" common_header.h stencil_assembly.cuh stencil_process.cuh >testbin/test.cu + +cd testbin +nvcc -std=c++11 test.cu -I ../samples -o test && ./test diff --git a/analysis/python/.gitignore b/analysis/python/.gitignore new file mode 100644 index 0000000..e33609d --- /dev/null +++ b/analysis/python/.gitignore @@ -0,0 +1 @@ +*.png diff --git a/analysis/python/README.md b/analysis/python/README.md new file mode 100644 index 0000000..865f23d --- /dev/null +++ b/analysis/python/README.md @@ -0,0 +1,7 @@ +# Python directory + +This directory is for Python script connected to data visualization and analysis. + +Content of this directory should be structured so that it is always callable by +`import astar` more task related scips should be written elsewhere, depending +the user's convenience. diff --git a/analysis/python/add_to_pythonpath.sh b/analysis/python/add_to_pythonpath.sh new file mode 100644 index 0000000..331b862 --- /dev/null +++ b/analysis/python/add_to_pythonpath.sh @@ -0,0 +1,3 @@ + + +export PYTHONPATH=${PYTHONPATH}:$PWD/ diff --git a/analysis/python/astar/__init__.py b/analysis/python/astar/__init__.py new file mode 100644 index 0000000..42c4a5b --- /dev/null +++ b/analysis/python/astar/__init__.py @@ -0,0 +1,24 @@ +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' + +# Developers note. We require Python 3 approach to have +# compatibility towards the future. + +import numpy as np +import pylab as plt diff --git a/analysis/python/astar/data/__init__.py b/analysis/python/astar/data/__init__.py new file mode 100644 index 0000000..0d767d2 --- /dev/null +++ b/analysis/python/astar/data/__init__.py @@ -0,0 +1,21 @@ +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' + + +from . import read diff --git a/analysis/python/astar/data/read.py b/analysis/python/astar/data/read.py new file mode 100644 index 0000000..17a7d05 --- /dev/null +++ b/analysis/python/astar/data/read.py @@ -0,0 +1,142 @@ +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' + +# This module is for reading data. + +import numpy as np + +def read_bin(fname, fdir, fnum, minfo, numtype=np.longdouble): + '''Read in a floating point array''' + filename = fdir + fname + '_' + fnum + '.mesh' + datas = np.DataSource() + read_ok = datas.exists(filename) + if read_ok: + print(filename) + array = np.fromfile(filename, dtype=numtype) + + timestamp = array[0] + + array = np.reshape(array[1:], (minfo.contents['AC_mx'], + minfo.contents['AC_my'], + minfo.contents['AC_mz']), order='F') + else: + array = None + timestamp = None + + return array, timestamp, read_ok + +def read_meshtxt(fdir, fname): + with open(fdir+fname) as f: + filetext = f.read().splitlines() + + contents = {} + + for line in filetext: + line = line.split() + if line[0] == 'int': + contents[line[1]] = np.int(line[2]) + elif line[0] == 'real': + contents[line[1]] = np.float(line[2]) + else: + print('ERROR: ' + line[0] +' no recognized!') + + return contents + +class MeshInfo(): + '''Object that contains all mesh info''' + + def __init__(self, fdir): + self.contents = read_meshtxt(fdir, 'mesh_info.list') + +class Mesh: + '''Class tha contains all 3d mesh data''' + + def __init__(self, fnum, fdir=""): + fnum = str(fnum) + self.framenum = fnum.zfill(10) + + self.minfo = MeshInfo(fdir) + + self.lnrho, self.timestamp, self.ok = read_bin('VTXBUF_LNRHO', fdir, fnum, self.minfo) + + if self.ok: + + self.ss, timestamp, ok = read_bin('VTXBUF_ENTROPY', fdir, fnum, self.minfo) + + #TODO Generalize is a dict. Do not hardcode! + uux, timestamp, ok = read_bin('VTXBUF_UUX', fdir, fnum, self.minfo) + uuy, timestamp, ok = read_bin('VTXBUF_UUY', fdir, fnum, self.minfo) + uuz, timestamp, ok = read_bin('VTXBUF_UUZ', fdir, fnum, self.minfo) + self.uu = (uux, uuy, uuz) + uux = [] + uuy = [] + uuz = [] + + aax, timestamp, ok = read_bin('VTXBUF_AX', fdir, fnum, self.minfo) + aay, timestamp, ok = read_bin('VTXBUF_AY', fdir, fnum, self.minfo) + aaz, timestamp, ok = read_bin('VTXBUF_AZ', fdir, fnum, self.minfo) + self.aa = (aax, aay, aaz) + aax = [] + aay = [] + aaz = [] + + self.xx = self.minfo.contents['AC_inv_dsx']*np.arange(self.minfo.contents['AC_mx']) + self.yy = self.minfo.contents['AC_inv_dsy']*np.arange(self.minfo.contents['AC_my']) + self.zz = self.minfo.contents['AC_inv_dsz']*np.arange(self.minfo.contents['AC_mz']) + + self.xmid = int(self.minfo.contents['AC_mx']/2) + self.ymid = int(self.minfo.contents['AC_my']/2) + self.zmid = int(self.minfo.contents['AC_mz']/2) + + +def parse_ts(fdir, fname): + with open(fdir+fname) as f: + filetext = f.read().splitlines() + + var = {} + + line = filetext[0].split() + for i in range(len(line)): + line[i] = line[i].replace('VTXBUF_', "") + line[i] = line[i].replace('UU', "uu") + line[i] = line[i].replace('_total', "tot") + line[i] = line[i].replace('A', "aa") + line[i] = line[i].replace('LNRHO', "lnrho") + line[i] = line[i].replace('X', "x") + line[i] = line[i].replace('Y', "y") + line[i] = line[i].replace('Z', "z") + + tsdata = np.loadtxt(fdir+fname,skiprows=1) + + for i in range(len(line)): + var[line[i]] = tsdata[:,i] + + var['step'] = np.int64(var['step']) + + print("HERE ARE ALL KEYS FOR TS DATA:") + print(var.keys()) + + return var + +class TimeSeries: + '''Class for time series data''' + + def __init__(self, fdir="", fname="timeseries.ts"): + + self.var = parse_ts(fdir, fname) diff --git a/analysis/python/astar/visual/__init__.py b/analysis/python/astar/visual/__init__.py new file mode 100644 index 0000000..44eca95 --- /dev/null +++ b/analysis/python/astar/visual/__init__.py @@ -0,0 +1,21 @@ +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' + + +from . import slices diff --git a/analysis/python/astar/visual/slices.py b/analysis/python/astar/visual/slices.py new file mode 100644 index 0000000..6afa71a --- /dev/null +++ b/analysis/python/astar/visual/slices.py @@ -0,0 +1,92 @@ + +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' +import pylab as plt +import numpy as np +import matplotlib.gridspec as gridspec +import matplotlib.colors as colors + +CM_INFERNO = plt.get_cmap('inferno') + +def plot_3(mesh, input_grid, title = '', fname = 'default', bitmap=False, slicetype = 'middle', colrange=None, colormap=CM_INFERNO , contourplot=False): + fig = plt.figure(figsize=(8, 8)) + grid = gridspec.GridSpec(2, 3, wspace=0.4, hspace=0.4, width_ratios=[1,1, 0.15]) + ax00 = fig.add_subplot( grid[0,0] ) + ax10 = fig.add_subplot( grid[0,1] ) + ax11 = fig.add_subplot( grid[1,1] ) + axcbar = fig.add_subplot( grid[:,2] ) + + print(mesh.minfo.contents.keys()) + + if slicetype == 'middle': + yz_slice = input_grid[mesh.xmid, :, :] + xz_slice = input_grid[:, mesh.ymid, :] + xy_slice = input_grid[:, :, mesh.zmid] + if colrange==None: + plotnorm = colors.Normalize(vmin=input_grid.min(),vmax=input_grid.max()) + else: + plotnorm = colors.Normalize(vmin=colrange[0],vmax=colrange[1]) + elif slicetype == 'sum': + yz_slice = np.sum(input_grid, axis=0) + xz_slice = np.sum(input_grid, axis=1) + xy_slice = np.sum(input_grid, axis=2) + cmin = np.amin([yz_slice.min(), xz_slice.min(), xy_slice.min()]) + cmax = np.amax([yz_slice.max(), xz_slice.max(), xy_slice.max()]) + if colrange==None: + plotnorm = colors.Normalize(vmin=cmin,vmax=cmax) + else: + plotnorm = colors.Normalize(vmin=colrange[0],vmax=colrange[1]) + + + yy, zz = np.meshgrid(mesh.yy, mesh.zz, indexing='ij') + if contourplot: + map1 = ax00.contourf(yy, zz, yz_slice, norm=plotnorm, cmap=colormap, nlev=10) + else: + map1 = ax00.pcolormesh(yy, zz, yz_slice, norm=plotnorm, cmap=colormap) + ax00.set_xlabel('y') + ax00.set_ylabel('z') + ax00.set_title('%s t = %.4e' % (title, mesh.timestamp) ) + ax00.set_aspect('equal') + + xx, zz = np.meshgrid(mesh.xx, mesh.zz, indexing='ij') + if contourplot: + ax10.contourf(xx, zz, xz_slice, norm=plotnorm, cmap=colormap, nlev=10) + else: + ax10.pcolormesh(xx, zz, xz_slice, norm=plotnorm, cmap=colormap) + ax10.set_xlabel('x') + ax10.set_ylabel('z') + ax10.set_aspect('equal') + + xx, yy = np.meshgrid(mesh.xx, mesh.yy, indexing='ij') + if contourplot: + ax11.contourf(xx, yy, xy_slice, norm=plotnorm, cmap=colormap, nlev=10) + else: + ax11.pcolormesh(xx, yy, xy_slice, norm=plotnorm, cmap=colormap) + ax11.set_xlabel('x') + ax11.set_ylabel('y') + ax11.set_aspect('equal') + + cbar = plt.colorbar(map1, cax=axcbar) + + if bitmap: + plt.savefig('%s_%s.png' % (fname, mesh.framenum)) + print('Saved %s_%s.png' % (fname, mesh.framenum)) + plt.close(fig) + + diff --git a/analysis/python/calc/convert.sh b/analysis/python/calc/convert.sh new file mode 100755 index 0000000..c444664 --- /dev/null +++ b/analysis/python/calc/convert.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +#gm convert -delay 40 colden_*.png colden.gif + +DATE=`date '+%Y_%m_%d_%H_%M'` + +echo $DATE + +gm convert -delay 15 $1_*.png $1_$DATE.gif diff --git a/analysis/python/calc/galli_shu_plotter.py b/analysis/python/calc/galli_shu_plotter.py new file mode 100644 index 0000000..38a5248 --- /dev/null +++ b/analysis/python/calc/galli_shu_plotter.py @@ -0,0 +1,835 @@ +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' +import numpy as np +import pylab as plt +import scipy as scp + +import matplotlib.colors as colors + +G_newton = 6.674e-8 #cm**3 g**-1 s**-2 + +# Time to convert to physical quantities +yr = 3.154e+7 #s +kyr = 1000.0*yr +km = 1e5 #cm +AU = 1.496e+13 #cm +Msun = 1.98847e33 #g + +#cs0 = 20000.0 #cs cm/s "a" in Shu notation +cs0 = 35000.0 #cs cm/s "a" in Shu notation +B0 = 30e-6 #G +ksii = 11.3 # + +#GS Eq. 10 +ttm = 9.03e12*(cs0/35000.0)/(B0/30e-6) + + +CM_INFERNO = plt.cm.get_cmap('inferno') + + + + + + +def P_harmonics(theta, J=666): + #Vector spherical harmonics in e_r direction + if J == 0: + P = np.ones_like(theta) # 1.0 + elif J == 2: + cos_theta = np.cos(theta) + P = (1.0/2.0)*(3.0*(cos_theta**2.0) - 1.0) + else: + P = 0.0 + + #print("P_2", P) + return P + + +def B_harmonics(theta, J=666): + #Vector spherical harmonics in e_theta direction + #print("B_harmonics theta", theta) + if J == 2: + sin_theta = np.abs(np.sin(theta)) + cos_theta = np.cos(theta) + #B = -(3.0/np.sqrt(6.0))*cos_theta*sin_theta #Morse & Feshbach 1953 book + B = -3.0*cos_theta*sin_theta #GS93 Appendix B + else: + B = 0.0*theta + + #print("B_harmonics", B) + + return B + +def get_tau(tt): + return tt/ttm + +def get_SHU77_potential(xx_point): + #Copied here again for convenience + m0 = 0.975 #Shu 77 core reduced mass + xx_SHU_table = np.array([ 0.05, 0.10, 0.15, 0.20, 0.25, + 0.30, 0.35, 0.40, 0.45, 0.50, + 0.55, 0.60, 0.65, 0.70, 0.75, + 0.80, 0.85, 0.90, 0.95, 1.00]) + + mm_SHU77_table = np.array([0.981, 0.993, 1.01, 1.03, 1.05, + 1.08, 1.12, 1.16, 1.20, 1.25, + 1.30, 1.36, 1.42, 1.49, 1.56, + 1.64, 1.72, 1.81, 1.90, 2.00]) + + xx = xx_SHU_table[ np.where(xx_SHU <= xx_point)] + mm = mm_SHU77_table[np.where(xx_SHU <= xx_point)] + + psi = - m0/xx_point + np.trapz(mm/(xx**2.0), xx) + + return psi + + +def psi2(xx_SHU, mm_term, pp_term, J=666): + #GS93 Eq. 113 + if J == 0: + psi2 = - mm_term/xx_SHU + pp_term + elif J == 2: + psi2 = - mm_term/(xx_SHU**3.0) + (xx_SHU**2.0)*pp_term + else: + psi2 = 0.0 + + #print('psi2', psi2, 'J', J, 'mm_term', mm_term, 'xx_SHU', xx_SHU, 'pp_term', pp_term) + + return psi2 + +# Calculate the directional parameter +def dv_dx(xx,vv, alpha): + EE = alpha*(xx-vv) - 2.0/xx + HH = (xx-vv)**2.0 - 1.0 + return (EE/HH)*(xx-vv) + +def dalpha_dx(xx,vv, alpha): + EE = alpha*(alpha - (2.0/xx)*(xx-vv)) + HH = (xx-vv)**2.0 - 1.0 + return (EE/HH)*(xx-vv) + +def dpsi_dx(xx, mm): + return mm/(xx**2.0) + +def dmm_dx(xx, alpha): + return (xx**2.0)*alpha + +def dphi_dx(xx, alpha, mm, theta): + ff_zero_der = 0.5*mm*dmm_dx(xx, alpha) + sin_theta = np.sin(theta) + return ff_zero_der*(sin_theta*2.0) + + +def deltaspace(theta, tau): + #Assuming J= 0, 2 only + v0 = -2.222e-1 + v2 = 2.177e-1 + deltaJ2 = -(1.0/3.0)*((v0+2.0/3.0)*P_harmonics(theta, J=0) + (v2 - 2.0/3.0)*P_harmonics(theta, J=2)) + delta = 1 + (tau**2.0)*deltaJ2 + return delta + +def delta2(theta, tau): + #Assuming J= 0, 2 only + return deltaspace(theta, tau)**2.0 + +def yy_transform(xx_SHU, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93): + + + + return alpha_mono_GS93, alpha_quad_GS93 + +# Calculating the perturbation stage +def alpha_perturb(tau, xx_SHU, vv_SHU77, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93, theta): + #Assuming J= 0, 2 only + directional = xx_SHU*dalpha_dx(xx_SHU, vv_SHU77, alpha_SHU77)*delta2(theta, tau) + directional = 0.0 # + alpha = alpha_mono_GS93*P_harmonics(theta, J=0) + alpha_quad_GS93*P_harmonics(theta, J=2) + directional + return alpha + +def vv_perturb(tau, xx_SHU, vv_SHU77, alpha_SHU77, vv_ww_mono_GS93, vv_ww_quad_GS93, theta): + #Assuming J= 0, 2 only + directional = xx_SHU*dv_dx(xx_SHU, vv_SHU77, alpha_SHU77)*delta2(theta, tau) + directional = 0.0 # + vv_mono = vv_ww_mono_GS93[0] + vv_quad = vv_ww_quad_GS93[0] + ww_mono = vv_ww_mono_GS93[1] + ww_quad = vv_ww_quad_GS93[1] + #print('vv_mono, vv_quad, ww_mono, ww_quad', vv_mono, vv_quad, ww_mono, ww_quad) + vv_r = vv_mono*P_harmonics(theta, J=0) + vv_quad*P_harmonics(theta, J=2) + directional ## vv + vv_theta = ww_mono*B_harmonics(theta, J=0) + ww_quad*B_harmonics(theta, J=2) + directional ## ww + #print("vv_r, vv_theta", vv_r, vv_theta) + vv = np.array([vv_r, vv_theta]) + return vv + +def psi_perturb(tau, xx_SHU, mm_SHU77, mm_pp_mono_GS93, mm_pp_quad_GS93, theta): + #Assuming J= 0, 2 only + directional = xx_SHU*dpsi_dx(xx_SHU, mm_SHU77)*delta2(theta, tau) + directional = 0.0 # + mm_mono = mm_pp_mono_GS93[0] + mm_quad = mm_pp_quad_GS93[0] + pp_mono = mm_pp_mono_GS93[1] + pp_quad = mm_pp_quad_GS93[1] + + #print('mm_pp_mono_GS93', mm_pp_mono_GS93) + #print('mm_mono', mm_mono) + + psi = psi2(xx_SHU, mm_mono, pp_mono, J=0)*P_harmonics(theta, J=0) \ + + psi2(xx_SHU, mm_quad, pp_quad, J=0)*P_harmonics(theta, J=2) \ + + directional + + #print('psi_perturb', psi) + + return psi + +def phi_vecpot_second_order(tau, xx_SHU, mm_SHU77, alpha_SHU77, FF_DD_mono_GS93, FF_DD_quad_GS93, theta): + directional = xx_SHU*dphi_dx(xx_SHU, alpha_SHU77, mm_SHU77, theta)*delta2(theta, tau) + directional = 0.0 # + sin_theta = np.sin(theta) + #print(FF_DD_mono_GS93) + #print(FF_DD_quad_GS93) + #print(ksii, P_harmonics(theta, J=0), P_harmonics(theta, J=2)) + mono_term = (FF_DD_mono_GS93[0] + (1.0/ksii)*FF_DD_mono_GS93[1]) + quad_term = (FF_DD_quad_GS93[0] + (1.0/ksii)*FF_DD_quad_GS93[1]) + phi_vecpot_second = (sin_theta**2.0)*( mono_term*P_harmonics(theta, J=0) \ + + quad_term*P_harmonics(theta, J=2) ) \ + + directional + return phi_vecpot_second + +def phi_vecpot_zero_order(xx_SHU, mm_SHU77, theta): + ff_zero = 0.25*(mm_SHU77**2.0) + sin_theta = np.sin(theta) + phi_vecpot_zero = ff_zero*(sin_theta*2.0) + return phi_vecpot_zero + + +# Combining the perturbation stage. +def alpha_xvec_tau(tau, xx_SHU, vv_SHU77, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93, theta): + alpha = alpha_SHU77 + (tau**2.0)*alpha_perturb(tau, xx_SHU, vv_SHU77, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93, theta) + return alpha + +def vv_xvec_tau(tau, xx_SHU, vv_SHU77, alpha_SHU77, vv_ww_mono_GS93, vv_ww_quad_GS93, theta): + vv = (tau**2.0)*vv_perturb(tau, xx_SHU, vv_SHU77, alpha_SHU77, vv_ww_mono_GS93, vv_ww_quad_GS93, theta) + #print("BF",vv, vv_ww_mono_GS93, vv_ww_quad_GS93) + vv[0] = vv_SHU77 + vv[0] + vv[1] = 0.0 + vv[1] #No poloidal velocity in Shu77 + #print("AF",vv) + return vv + +def psi_xvec_tau(tau, xx_SHU, mm_SHU77, mm_pp_mono, mm_pp_quad, theta): + #print("psi_xvec_tau --- tau, xx_SHU, mm_SHU7, mm_pp_mono, mm_pp_quad, theta", tau, xx_SHU, mm_SHU77, mm_pp_mono, mm_pp_quad, theta) + psi = (tau**2.0)*psi_perturb(tau, xx_SHU, mm_SHU77, mm_pp_mono, mm_pp_quad, theta) + psi77 = get_SHU77_potential(xx_SHU) + #print('psi77', psi77) + psi = psi77 + psi + #print('psi_xvec_tau', psi) + return psi + + +def phi_vecpot_xvec_tau(tau, xx_SHU, mm_SHU77, alpha_SHU77, FF_DD_mono_GS93, FF_DD_quad_GS93, theta): + phi_vecpot_second = (tau**2.0)*phi_vecpot_second_order(tau, xx_SHU, mm_SHU77, alpha_SHU77, FF_DD_mono_GS93, FF_DD_quad_GS93, theta) + phi_vecpot_zero = phi_vecpot_zero_order(xx_SHU, mm_SHU77, theta) + phi_vecpot = phi_vecpot_zero + phi_vecpot_second + return phi_vecpot + +#Physical unit converion stage +def rho_rt(tt, xx_SHU, vv_SHU77, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93, theta): + tau = get_tau(tt) + alpha_xvec = alpha_xvec_tau(tau, xx_SHU, vv_SHU77, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93, theta) + rho = (1.0/(4.0*np.pi*G_newton*(tt**2.0))) * alpha_xvec + return rho, alpha_xvec + +def uu_rt(tt, xx_SHU, vv_SHU77, alpha_SHU77, vv_ww_mono_GS93, vv_ww_quad_GS93, theta): + tau = get_tau(tt) + vv_xvec = vv_xvec_tau(tau, xx_SHU, vv_SHU77, alpha_SHU77, vv_ww_mono_GS93, vv_ww_quad_GS93, theta) + uu = cs0*vv_xvec + return uu, vv_xvec + +def grav_psi_rt(tt, xx_SHU, mm_SHU77, mm_pp_mono, mm_pp_quad, theta): + tau = get_tau(tt) + #print("tt , xx_SHU, mm_SHU77, mm_pp_mono, mm_pp_quad, theta", tt, xx_SHU, mm_SHU77, mm_pp_mono, mm_pp_quad, theta) + psi_xvec = psi_xvec_tau(tau, xx_SHU, mm_SHU77, mm_pp_mono, mm_pp_quad, theta) + Vpot = (cs0**2.0)*psi_xvec + return Vpot, psi_xvec + +def vectorpot_rt(tt, xx_SHU, mm_SHU77, alpha_SHU77, FF_DD_mono_GS93, FF_DD_quad_GS93, theta): + tau = get_tau(tt) + phi_vecpot_xvec = phi_vecpot_xvec_tau(tau, xx_SHU, mm_SHU77, alpha_SHU77, FF_DD_mono_GS93, FF_DD_quad_GS93, theta) + Phi_flux = np.pi*B0*((cs0*tt)**2.0)*phi_vecpot_xvec + return Phi_flux, phi_vecpot_xvec + + + +###def match_xx(xx_rad, xx_SHU): +### xx_buffer = np.empty_like(xx_rad) +### stride = np.abs(xx_SHU[1] - xx_SHU[0]) +### for xx in xx_SHU: +### #where xx - stride < xx_rad < xx + stride -> xx_rad[i] = xx +### #loc = np.where((xx_rad <= (xx + stride) and xx_rad > (xx - stride) )) +### loc = np.where(xx_rad <= (xx + stride) ) +### print(loc) + + +def get_shu_index(xx, xx_SHU): + stride = np.abs(xx_SHU[1] - xx_SHU[0])/2.0 + + #ishu = np.where((xx_SHU <= (xx + stride)) & (xx_SHU > (xx - stride)))[0] + + + #TODO Now a purkka version. Do better. + # Can be improve by taking the treatment of the actual low and high x cases. + if (xx > xx_SHU[xx_SHU.size-1]): + ishu = xx_SHU.size-1 + elif (xx < xx_SHU[0]): + ishu = 0 + else: + ishu = np.where((xx_SHU <= (xx + stride)) & (xx_SHU > (xx - stride)))[0] + #print("get_shu_index", ishu, ishu.size) + ishu = ishu[0] + #print("get_shu_index", ishu, ishu.size) + + #print(ishu, xx_SHU[ishu], xx) + + return ishu + +def plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, xxvar, physvar, + vv_hor=np.array(None), vv_ver=np.array(None), uu_hor=np.array(None), uu_ver=np.array(None), + title1=r"\alpha", title2=r"\rho", filetitle='density', + var_min=[None, None], var_max=[None, None], colmap=CM_INFERNO, normtype='log', + streamlines = 0, contourplot = 0): + + if var_min[0] != None: + if normtype == 'log': + mynorm1 = colors.LogNorm( vmin=var_min[0], vmax=var_max[0] ) + mynorm2 = colors.LogNorm( vmin=var_min[1], vmax=var_max[1] ) + else: + mynorm1 = colors.Normalize( vmin=var_min[0], vmax=var_max[0] ) + mynorm2 = colors.Normalize( vmin=var_min[1], vmax=var_max[1] ) + else: + mynorm1 = colors.Normalize( ) + mynorm2 = colors.Normalize( ) + + if contourplot: + if normtype =='cdensity': + numbers = np.arange(0, 20, dtype=np.float64) + contourlevs = 1e-20*(np.sqrt(2.0)**numbers) + contournorm = colors.LogNorm( vmin=contourlevs.min(), vmax=contourlevs.max() ) + elif normtype =='cflux': + contourlevs = np.linspace(1.0, 1e31, num=20) + contournorm = colors.Normalize( vmin=contourlevs.min(), vmax=contourlevs.max() ) + else: + contourlevs = np.linspace(physvar.min(), physvar.max(), num=10) + contournorm = colors.Normalize( vmin=contourlevs.min(), vmax=contourlevs.max() ) + + + ##rr_horizontal_corners = xx_horizontal_corners*(cs0*tt)/AU + ##rr_vertical_corners = xx_vertical_corners* (cs0*tt)/AU + ##rr_horizontal = xx_horizontal*(cs0*tt)/AU + ##rr_vertical = xx_vertical* (cs0*tt)/AU + + rr_horizontal_corners = xx_horizontal_corners*(cs0*tt)/1e17 + rr_vertical_corners = xx_vertical_corners* (cs0*tt)/1e17 + rr_horizontal = xx_horizontal*(cs0*tt)/1e17 + rr_vertical = xx_vertical* (cs0*tt)/1e17 + + + + figa, axa = plt.subplots(nrows=1, ncols=2, figsize=(16,6)) + if contourplot: + mapa = axa[0].contourf(xx_horizontal, xx_vertical, xxvar, cmap=colmap, norm=mynorm1) + maprho = axa[1].contourf(rr_horizontal, rr_vertical, physvar, contourlevs, cmap=colmap, norm=contournorm) + else: + mapa = axa[0].pcolormesh(xx_horizontal_corners, xx_vertical_corners, xxvar, cmap=colmap, norm=mynorm1 ) + maprho = axa[1].pcolormesh(rr_horizontal_corners, rr_vertical_corners, physvar, cmap=colmap, norm=mynorm2) + + #mapa = axa[0].contourf(xx_horizontal, xx_vertical, alpha, cmap=CM_INFERNO, norm=colors.LogNorm(vmin=0.1, vmax=50.0)) + #maprho = axa[1].contourf(xx_horizontal*(cs0*tt)/AU, xx_vertical*(cs0*tt)/AU, rho, cmap=CM_INFERNO, norm=colors.LogNorm(vmin=1e15, vmax=1e20)) + + if vv_hor.any() != None: + if streamlines: + #vv_tot = np.sqrt(vv_hor**2.0 + vv_ver**2.0) + #vv_tot = np.log(vv_tot/vv_tot.max()) + axa[0].streamplot(xx_horizontal, xx_vertical, vv_hor, vv_ver, color = 'k') + axa[1].streamplot(rr_horizontal, rr_vertical, uu_hor, uu_ver, color = 'k' ) + else: + axa[0].quiver(xx_horizontal, xx_vertical, vv_hor, vv_ver, pivot = 'middle') + axa[1].quiver(rr_horizontal, rr_vertical, uu_hor, uu_ver, pivot = 'middle') + + fig.colorbar(mapa, ax=axa[0]) + fig.colorbar(maprho, ax=axa[1]) + + tau = get_tau(tt) + tt_kyr = tt/kyr + axa[0].set_title(r'$%s(x, \tau = %.3f)$ ' % (title1, tau)) + axa[1].set_title(r'$%s(r, t = %.3f \mathrm{kyr})$ ' % (title2, tt_kyr)) + + axa[0].set_xlabel('x') + axa[0].set_ylabel('x') + #axa[1].set_xlabel('r (AU)') + #axa[1].set_ylabel('r (AU)') + axa[1].set_xlabel(r'r ($10^{17}$ cm)') + axa[1].set_ylabel(r'r ($10^{17}$ cm)' ) + + ##axa[1].set_xlim(0.0, 3e17/AU) + ##axa[1].set_ylim(0.0, 3e17/AU) + axa[1].set_xlim(0.0, 3.0) + axa[1].set_ylim(0.0, 3.0) + + axa[0].set_aspect('equal', 'datalim') + #axa[1].set_aspect('equal', 'datalim') + + figfile = '%s_%s.png' % (filetitle, str(numslice).zfill(6)) + print(figfile) + figa.savefig(figfile) + plt.close(figa) + + + +xx_SHU = np.array([ 0.05, 0.10, 0.15, 0.20, 0.25, + 0.30, 0.35, 0.40, 0.45, 0.50, + 0.55, 0.60, 0.65, 0.70, 0.75, + 0.80, 0.85, 0.90, 0.95, 1.00]) + +alpha_SHU77 = np.array([ 71.5, 27.8, 16.4, 11.5, 8.76, + 7.09, 5.95, 5.14, 4.52, 4.04, + 3.66, 3.35, 3.08, 2.86, 2.67, + 2.50, 2.35, 2.22, 2.10, 2.00]) + +vv_SHU77 = -np.array([ 5.44, 3.47, 2.58, 2.05, 1.68, + 1.40, 1.18, 1.01, 0.861, 0.735, + 0.625, 0.528, 0.442, 0.363, 0.291, + 0.225, 0.163, 0.106, 0.051, 0.00]) + +mm_SHU77 = np.array([0.981, 0.993, 1.01, 1.03, 1.05, + 1.08, 1.12, 1.16, 1.20, 1.25, + 1.30, 1.36, 1.42, 1.49, 1.56, + 1.64, 1.72, 1.81, 1.90, 2.00]) + + + + +#GS Table 1 + +alpha_mono_GS93 = np.array([ 6.304, 2.600, 1.652, 1.156, 9.005e-1, + 7.314e-1, 6.084e-1, 5.084e-1, 4.256e-1, 3.517e-1, + 2.829e-1, 2.172e-1, 1.488e-1, 8.091e-2, 8.360e-3, + -6.826e-2, -1.512e-1, -2.406e-1, -3.382e-1, -4.444e-1]) + +vv_ww_mono_GS93 = np.array([[4.372e-1, 3.335e-1, 2.390e-1, 1.918e-1, 1.522e-1, + 1.226e-1, 9.579e-2, 7.103e-2, 4.828e-2, 2.640e-2, + 5.058e-3, -1.588e-2, -3.791e-2, -5.975e-2, -8.293e-2, + -1.071e-1, -1.330e-1, -1.605e-1, -1.902e-1, -2.222e-1], + [ 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0]]) + +mm_pp_mono_GS93 = np.array([[8.634e-4, 1.959e-3, 3.560e-3, 5.661e-3, 8.235e-3, + 1.130e-2, 1.482e-2, 1.873e-2, 2.293e-2, 2.730e-2, + 3.166e-2, 3.579e-2, 3.935e-2, 4.196e-2, 4.312e-2, + 4.221e-2, 3.847e-2, 3.097e-2, 1.859e-2, 0.0], + [ 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0]]) + + +FF_DD_mono_GS93 = np.array([[ -1.130, -3.275e-1, -1.355e-1, -6.415e-2, -2.889e-2, #F + -8.387e-3, 5.358e-3, 1.534e-2, 2.303e-2, 2.931e-2, + 3.454e-2, 3.888e-2, 4.225e-2, 4.442e-2, 4.504e-2, + 4.358e-2, 3.935e-2, 3.146e-2, 1.881e-2, 0.0], + [ -1.246e1, -3.168, -1.141, -5.740e-1, -3.178e-1, #D + -1.878e-1, -1.049e-1, -4.547e-2, 3.393e-4, 3.924e-2, + 7.431e-2, 1.070e-1, 1.376e-1, 1.650e-1, 1.867e-1, + 1.992e-1, 1.966e-1, 1.708e-1, 1.103e-1, 0.0]]) + + + +#GS Table 2 + +alpha_quad_GS93 = np.array([ -1.096e3, -1.191e2, -3.148e1, -1.158e1, -5.105, + -2.456, -1.217, -5.889e-1, -2.569e-1, -7.024e-2, + 3.790e-2, 1.042e-1, 1.505e-1, 1.845e-1, 2.163e-1, + 2.492e-1, 2.865e-1, 3.302e-1, 3.823e-1, 4.437e-1]) + +vv_ww_quad_GS93 = np.array([[ -2.581, -1.533, -8.072e-1, -5.666e-1, -3.905e-1, #v + -2.790e-1, -1.928e-1, -1.254e-1, -7.156e-2, -2.614e-2, + 1.267e-2, 4.650e-2, 7.724e-2, 1.042e-1, 1.288e-1, + 1.510e-1, 1.711e-1, 1.889e-1, 2.045e-1, 2.177e-1], + [ -2.085, -4.890, -1.811, -8.842e-1, -4.816e-1, #w + -2.807e-1, -1.628e-1, -8.779e-2, -3.852e-2, -4.481e-3, + 1.928e-2, 3.578e-2, 4.683e-2, 5.306e-2, 5.512e-2, + 5.312e-2, 4.704e-2, 3.670e-2, 2.179e-2, 1.898e-3]]) + +mm_pp_quad_GS93 = np.array([[-3.860e-5, -1.541e-4, -3.044e-4, -4.847e-4, -6.831e-4, #m + -8.874e-4, -1.083e-3, -1.253e-3, -1.385e-3, -1.462e-3, + -1.470e-3, -1.389e-3, -1.191e-3, -8.405e-4, -2.841e-4, + 5.579e-4, 1.800e-3, 3.609e-3, 6.218e-3, 9.951e-3], + [ -7.539e1, -7.275, -1.730, -5.586e-1, -1.999e-1, #p + -6.591e-1, -1.062e-2, 1.294e-2, 2.267e-2, 2.600e-2, + 2.625e-2, 2.500e-2, 2.294e-2, 2.046e-2, 1.769e-2, + 1.469e-2, 1.146e-2, 7.941e-3, 4.102e-3, -1.214e-4]]) + +FF_DD_quad_GS93 = np.array([[ -2.253, -6.517e-1, -2.722e-1, -1.345e-1, -6.993e-2, #F + -3.593e-2, -1.660e-2, -5.864e-3, -6.809e-4, 8.213e-4, + -3.086e-4, -3.338e-3, -7.681e-3, -1.272e-2, -1.778e-2, + -2.191e-2, -2.392e-2, -2.219e-2, -1.457e-2, 1.729e-3], + [ -2.484e1, -6.258, -2.221, -1.102, -6.127e-1, #D + -3.645e-1, -2.213e-1, -1.297e-1, -7.020e-2, -1.112e-2, + -2.139e-3, -1.615e-2, 2.744e-2, 3.252e-2, 3.269e-2, + 2.839e-2, 2.104e-2, 1.199e-2, 3.732e-3, 0.0]]) + + +tt = 0.3*ttm +theta = 0.5*np.pi + + +xx_SHU = xx_SHU[:-1] +vv_SHU77 = vv_SHU77[:-1] +alpha_SHU77 = alpha_SHU77[:-1] + +alpha_mono_GS93 = alpha_mono_GS93[:-1] +alpha_quad_GS93 = alpha_quad_GS93[:-1] + +vv_ww_mono_GS93 = np.array([vv_ww_mono_GS93[0][:-1], vv_ww_mono_GS93[1][:-1]]) +vv_ww_quad_GS93 = np.array([vv_ww_quad_GS93[0][:-1], vv_ww_quad_GS93[1][:-1]]) + + +rho, alpha_xvec = rho_rt(tt, xx_SHU, vv_SHU77, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93, theta) + +rr = xx_SHU*cs0*tt + +np.set_printoptions(linewidth=200) + +print(rho.shape) +print(xx_SHU.shape) + +print(rho) +print(xx_SHU) + +print(vv_ww_mono_GS93) +print(vv_ww_quad_GS93) +print(vv_ww_quad_GS93[0]) +print(vv_ww_quad_GS93[1]) + +#plt.figure() +#plt.plot(rr, rho) +# +#plt.figure() +#plt.plot(xx_SHU, alpha_xvec, label = "GS93") +#plt.plot(xx_SHU, alpha_SHU77, label = "Shu77") +#plt.legend() + + +#alpha_mono_yy, alpha_quad_yy, alpha_mono_yy = yy_transform(xx_SHU, alpha_SHU77, alpha_mono_GS93, alpha_quad_GS93) + + +plt.figure() +plt.plot(xx_SHU, alpha_SHU77, label=r"$\alpha^{(0)}$") +plt.plot(xx_SHU, alpha_mono_GS93, label=r"$\alpha^{(2)}_0$") +plt.plot(xx_SHU, alpha_quad_GS93, label=r"$\alpha^{(2)}_2$") +plt.ylim([-5.0,5.0]) +plt.legend() +plt.show() + + +''' +ii = 0 +theta_axis = np.linspace(0.0, np.pi) +xx_theta = np.array([]) + +print("PIIP") + + +plt.figure() +for ii in range(0,xx_SHU.size): + alpha_theta = np.array([]) + alpha_shuref = np.array([]) + for theta in theta_axis: + rho, alpha_xvec = rho_rt(tt, xx_SHU[ii], vv_SHU77[ii], alpha_SHU77[ii], alpha_mono_GS93[ii], alpha_quad_GS93[ii]) + alpha_theta = np.append(alpha_theta, alpha_xvec) + alpha_shuref = np.append(alpha_shuref, alpha_SHU77[ii]) + + plt.plot(alpha_theta, theta_axis, label = "GS93") + #plt.plot(alpha_shuref, theta_axis, label = "GS93") +''' + + +#Interpolate a mesh. + +xx_SHU_GRID = np.insert(xx_SHU, 0, 0.0) +print(xx_SHU_GRID) + +xx_horizontal, xx_vertical = np.meshgrid(xx_SHU_GRID, xx_SHU_GRID, indexing='xy') +theta = np.arctan2(xx_horizontal, xx_vertical) + +#Take pcolormesh coordinate system into account, which marks corners instead of centre points. +dxx = np.abs(xx_horizontal[0,1] - xx_horizontal[0,0]) + +print(dxx) +xx_horizontal_corners = xx_horizontal - dxx/2.0 +xx_vertical_corners = xx_vertical - dxx/2.0 + +xx_rad = np.sqrt(xx_horizontal**2.0 + xx_vertical**2.0) + + + + +fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(16,4)) + +map1 = ax[0].pcolormesh(xx_horizontal_corners, xx_vertical_corners, theta) +map2 = ax[1].pcolormesh(xx_horizontal_corners, xx_vertical_corners, xx_rad) + +ax[0].set_title(r"$\theta$") +ax[1].set_title(r"$x_\mathrm{rad}$") + +fig.colorbar(map1, ax=ax[0]) +fig.colorbar(map2, ax=ax[1]) + +ax[0].set_aspect('equal', 'datalim') +ax[1].set_aspect('equal', 'datalim') + + + + +Pfig, Pax = plt.subplots(nrows=1, ncols=3, figsize=(16,4)) + +print("P_harmonics(theta, J=0)", P_harmonics(theta, J=0)) + +Pmap1 = Pax[0].pcolormesh(xx_horizontal_corners, xx_vertical_corners, P_harmonics(theta, J=0)) +Pmap2 = Pax[1].pcolormesh(xx_horizontal_corners, xx_vertical_corners, P_harmonics(theta, J=2)) +Pmap3 = Pax[2].pcolormesh(xx_horizontal_corners, xx_vertical_corners, deltaspace(theta, 0.5)) + +Pax[0].set_title(r"$P_0(\theta)$") +Pax[1].set_title(r"$P_2(\theta)$") +Pax[2].set_title(r"$\Delta(\theta, \tau = 0.5)$") + + +Pfig.colorbar(Pmap1, ax=Pax[0]) +Pfig.colorbar(Pmap2, ax=Pax[1]) +Pfig.colorbar(Pmap3, ax=Pax[2]) + +Pax[0].set_aspect('equal', 'datalim') +Pax[1].set_aspect('equal', 'datalim') +Pax[2].set_aspect('equal', 'datalim') + + + + +Bfig, Bax = plt.subplots(nrows=1, ncols=2, figsize=(16,4)) + +print("B_harmonics(theta, J=0)", B_harmonics(theta, J=0)) + +Bmap1 = Bax[0].pcolormesh(xx_horizontal_corners, xx_vertical_corners, B_harmonics(theta, J=0)) +Bmap2 = Bax[1].pcolormesh(xx_horizontal_corners, xx_vertical_corners, B_harmonics(theta, J=2)) + +Bax[0].set_title(r"$B_0(\theta)$") +Bax[1].set_title(r"$B_2(\theta)$") + +Bfig.colorbar(Bmap1, ax=Bax[0]) +Bfig.colorbar(Bmap2, ax=Bax[1]) + +Bax[0].set_aspect('equal', 'datalim') +Bax[1].set_aspect('equal', 'datalim') + + +plt.show() + + + +##xx_horizontal_corners = np.append(xx_horizontal_corners, (np.amax(xx_horizontal_corners)+dxx)*np.ones((xx_horizontal_corners.shape[1],1)), axis=1) + +print(xx_horizontal_corners[-1,:]) +print(xx_horizontal_corners) + +##xx_horizontal_corners = np.vstack((xx_horizontal_corners, xx_horizontal_corners[-1,:])) +##print(xx_horizontal_corners) + +##xx_vertical_corners = np.append(xx_vertical_corners, (np.amax(xx_vertical_corners)+dxx)*np.ones((1,xx_vertical_corners.shape[0])), axis=0) + +print(xx_vertical_corners[:, -1]) +print(xx_vertical_corners) +##xx_vertical_corners = np.hstack((xx_vertical_corners, xx_vertical_corners[:,-1])) +print(xx_vertical_corners) + +numslice = 0 +frametot = 201 +#frametot = 101 +#frametot = 11 +for tt in np.linspace(0.1, ttm, num=frametot): + + alpha = np.empty_like(xx_rad) + alpha77 = np.empty_like(xx_rad) + rho = np.empty_like(xx_rad) + + vv_rad = np.empty_like(xx_rad) + vv_pol = np.empty_like(xx_rad) + uu_rad = np.empty_like(xx_rad) + uu_pol = np.empty_like(xx_rad) + + psi = np.empty_like(xx_rad) + Vpot = np.empty_like(xx_rad) + + Delta = np.empty_like(xx_rad) + + Phi_flux = np.empty_like(xx_rad) + phi_vecpot = np.empty_like(xx_rad) + + + alpha_2_J = np.empty_like(xx_rad) + + for ii in range(xx_SHU_GRID.size): + for kk in range(xx_SHU_GRID.size): + xx = xx_rad[ii,kk] + th = theta[ii,kk] + ishu = get_shu_index(xx, xx_SHU) + rho[ii, kk], alpha[ii, kk] = rho_rt(tt, xx_SHU[ishu], + vv_SHU77[ishu], + alpha_SHU77[ishu], + alpha_mono_GS93[ishu], + alpha_quad_GS93[ishu], th) + alpha77[ii, kk] = alpha_SHU77[ishu] + + vv_ww_mono_point = vv_ww_mono_GS93[:, ishu] + vv_ww_quad_point = vv_ww_quad_GS93[:, ishu] + uu_dump, vv_dump = uu_rt(tt, xx_SHU[ishu], vv_SHU77[ishu], alpha_SHU77[ishu], vv_ww_mono_point, vv_ww_quad_point, th) + vv_rad[ii, kk] = vv_dump[0] + vv_pol[ii, kk] = vv_dump[1] + uu_rad[ii, kk] = uu_dump[0] + uu_pol[ii, kk] = uu_dump[1] + + mm_pp_mono_point = mm_pp_mono_GS93[:, ishu] + mm_pp_quad_point = mm_pp_quad_GS93[:, ishu] + Vpot[ii, kk], psi[ii, kk] = grav_psi_rt(tt, xx_SHU[ishu], mm_SHU77[ishu], mm_pp_mono_point, mm_pp_quad_point, th) + + Phi_flux[ii, kk], phi_vecpot[ii, kk] = vectorpot_rt(tt, xx_SHU[ishu], mm_SHU77[ishu], alpha_SHU77[ishu], + FF_DD_mono_GS93[:, ishu], + FF_DD_quad_GS93[:, ishu], th) + + Delta[ii, kk] = deltaspace(th, get_tau(tt)) + alpha_2_J[ii, kk] = alpha_mono_GS93[ishu]*P_harmonics(th, J=0) + alpha_quad_GS93[ishu]*P_harmonics(th, J=2) + + + vv_hor = vv_pol*np.cos(theta) + vv_rad*np.sin(theta) + vv_ver = - vv_pol*np.sin(theta) + vv_rad*np.cos(theta) + uu_hor = uu_pol*np.cos(theta) + uu_rad*np.sin(theta) + uu_ver = - uu_pol*np.sin(theta) + uu_rad*np.cos(theta) + + + rho77 = alpha77 * (1.0/(4.0*np.pi*G_newton)*tt) #TODO WRONG COEFFS!!! + + + #Apply mask + + rad_mask = 0.2 + + + alpha = np.ma.masked_where(xx_rad < rad_mask, alpha) + rho = np.ma.masked_where(xx_rad < rad_mask, rho) + + vv_rad = np.ma.masked_where(xx_rad < rad_mask, vv_rad) + uu_rad = np.ma.masked_where(xx_rad < rad_mask, uu_rad) + vv_pol = np.ma.masked_where(xx_rad < rad_mask, vv_pol) + uu_pol = np.ma.masked_where(xx_rad < rad_mask, uu_pol) + + vv_hor = np.ma.masked_where(xx_rad < rad_mask, vv_hor) + vv_ver = np.ma.masked_where(xx_rad < rad_mask, vv_ver) + uu_hor = np.ma.masked_where(xx_rad < rad_mask, uu_hor) + uu_ver = np.ma.masked_where(xx_rad < rad_mask, uu_ver) + + psi = np.ma.masked_where(xx_rad < rad_mask, psi ) + Vpot = np.ma.masked_where(xx_rad < rad_mask, Vpot) + + phi_vecpot = np.ma.masked_where(xx_rad < rad_mask, phi_vecpot) + Phi_flux = np.ma.masked_where(xx_rad < rad_mask, Phi_flux ) + + alpha_2_J = np.ma.masked_where(xx_rad < rad_mask, alpha_2_J) + Delta = np.ma.masked_where(xx_rad < rad_mask, Delta ) + + plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, alpha, rho, + vv_hor=vv_hor, vv_ver=vv_ver, uu_hor=uu_hor, uu_ver=uu_ver, + title1=r"\alpha", title2=r"\rho", filetitle='GS93density', + streamlines = 1, contourplot=1, + var_min=[0.00, 1e15], var_max=[16, 1e21], + normtype = 'cdensity') + + plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, alpha77, rho77, + #var_min=[0.00, 0], var_max=[16, 1e20], + title1=r"\alpha", title2=r"\rho", filetitle='S77density') + + plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, vv_rad, uu_rad, + vv_hor=vv_hor, vv_ver=vv_ver, uu_hor=uu_hor, uu_ver=uu_ver, + title1=r"v_r", title2=r"u_r", filetitle='GS93velocity_rad', + var_min=[-2.5, -2.5*cs0], var_max=[0.0, 0.0*cs0], + normtype = 'lin') + + plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, vv_pol, uu_pol, + vv_hor=vv_hor, vv_ver=vv_ver, uu_hor=uu_hor, uu_ver=uu_ver, + title1=r"v_\theta", title2=r"u_\theta", filetitle='GS93velocity_pol', + var_min=[0.0, 0.0*cs0], var_max=[0.5, 0.5*cs0], + normtype = 'lin') + + + plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, psi, Vpot, + vv_hor=vv_hor, vv_ver=vv_ver, uu_hor=uu_hor, uu_ver=uu_ver, + title1=r"\psi", title2=r"V_\mathrm{pot}", filetitle='GS93gravpot', + var_min=[12.0, 12.0*(cs0**2.0)], var_max=[21.0, 21.0*(cs0**2.0)], + normtype = 'lin') + + plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, phi_vecpot, Phi_flux, + title1=r"\phi", title2=r"\Phi_\mathrm{flux}", filetitle='GS93vecpot', + vv_hor=vv_hor, vv_ver=vv_ver, uu_hor=uu_hor, uu_ver=uu_ver, + streamlines = 1, contourplot=1, + normtype = 'cflux') + + plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, np.sqrt(vv_hor**2.0 + vv_ver**2.0), np.sqrt(uu_hor**2.0 + uu_ver**2.0), + title1=r"|v|", title2=r"|u| (cm/s)", filetitle='GS93vel2', + var_min=[0.0, 0.0*cs0], var_max=[2.5, 2.5*cs0], + vv_hor=vv_hor, vv_ver=vv_ver, uu_hor=uu_hor, uu_ver=uu_ver, + streamlines = 1, + normtype = 'lin') + + + ##plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, Delta, Delta, + ## title1=r"\Delta", title2=r"\Delta", filetitle='Delta', + ## normtype = 'lin') + + ##plot_figure(tt, xx_horizontal_corners, xx_vertical_corners, xx_horizontal, xx_vertical, alpha_2_J, alpha_2_J, + ## title1=r"\sum \alpha^{(2)}_J", title2=r"\sum \alpha^{(2)}_J", filetitle='alpha_2_J', + ## normtype = 'lin') + + numslice += 1 + + + + + + + + + + + + + + + + + + + diff --git a/analysis/python/calc/purge.sh b/analysis/python/calc/purge.sh new file mode 100755 index 0000000..8723972 --- /dev/null +++ b/analysis/python/calc/purge.sh @@ -0,0 +1 @@ +rm *.png diff --git a/analysis/python/calc/shu_selfsim.py b/analysis/python/calc/shu_selfsim.py new file mode 100644 index 0000000..357aa63 --- /dev/null +++ b/analysis/python/calc/shu_selfsim.py @@ -0,0 +1,279 @@ +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' +import numpy as np +import pylab as plt + +G_newton = 6.674e-8 #cm**3 g**-1 s**-2 + +def dv_dx(xx,vv, alpha): + EE = alpha*(xx-vv) - 2.0/xx + HH = (xx-vv)**2.0 - 1.0 + return (EE/HH)*(xx-vv) + +def dalpha_dx(xx,vv, alpha): + EE = alpha*(alpha - (2.0/xx)*(xx-vv)) + HH = (xx-vv)**2.0 - 1.0 + return (EE/HH)*(xx-vv) + +###def dv_dx(xx,vv, alpha): +### return 2.0*(xx-vv) +### +###def dalpha_dx(xx,vv, alpha): +### return -1.0*(xx-vv) + +def get_m(xx, vv, alpha): + mm = xx**2.0 * alpha * (xx-vv) + return mm + +def alpha_to_rho(alpha, tt): + rho = alpha/(4.0*np.pi*G_newton*(tt**2.0)) + return rho + +def vv_to_uu(vv, cs0): + uu = cs0*vv + return uu + +def mm_to_MM(mm, tt, cs0): + MM = (((cs0**3.0)*tt)/G_newton)*mm + return MM + +def euler(xx_step, xx, vv, alpha, mm, target): + diff = target - xx[-1] + if diff >= 0: + while xx[-1] <= target: + vv_step = vv[-1] + xx_step*dv_dx(xx[-1], vv[-1], alpha[-1]) + alpha_step = alpha[-1] + xx_step*dalpha_dx(xx[-1], vv[-1], alpha[-1]) + + xx = np.append(xx, xx[-1]+xx_step) + alpha = np.append(alpha, alpha_step) + vv = np.append(vv, vv_step) + mm_step = get_m(xx[-1], vv[-1], alpha[-1]) + mm = np.append(mm, mm_step) + else: + while xx[-1] <= target: + vv_step = vv[-1] + xx_step*dv_dx(xx[-1], vv[-1], alpha[-1]) + alpha_step = alpha[-1] + xx_step*dalpha_dx(xx[-1], vv[-1], alpha[-1]) + + xx = np.append(xx, xx[-1]+xx_step) + alpha = np.append(alpha, alpha_step) + vv = np.append(vv, vv_step) + mm_step = get_m(xx[-1], vv[-1], alpha[-1]) + mm = np.append(mm, mm_step) + return xx, vv, alpha, mm + +def RK4_step(vv, xx, alpha, xx_step): + vv1 = xx_step*dv_dx(xx[-1], vv[-1], alpha[-1]) + alpha1 = xx_step*dalpha_dx(xx[-1], vv[-1], alpha[-1]) + + vv2 = xx_step*dv_dx(xx[-1]+xx_step/2.0, vv[-1]+vv1/2.0, alpha[-1]+alpha1/2.0) + alpha2 = xx_step*dalpha_dx(xx[-1]+xx_step/2.0, vv[-1]+vv1/2.0, alpha[-1]+alpha1/2.0) + + vv3 = xx_step*dv_dx(xx[-1]+xx_step/2.0, vv[-1]+vv2/2.0, alpha[-1]+alpha2/2.0) + alpha3 = xx_step*dalpha_dx(xx[-1]+xx_step/2.0, vv[-1]+vv2/2.0, alpha[-1]+alpha2/2.0) + + vv4 = xx_step*dv_dx(xx[-1]+xx_step, vv[-1]+vv3, alpha[-1]+alpha3) + alpha4 = xx_step*dalpha_dx(xx[-1]+xx_step, vv[-1]+vv3, alpha[-1]+alpha3) + + vv_step = vv[-1] + (1.0/6.0)*(vv1 + 2.0*vv2 + 2.0*vv3 + vv4) + alpha_step = alpha[-1] + (1.0/6.0)*(alpha1 + 2.0*alpha2 + 2.0*alpha3 + alpha4) + + return vv_step, alpha_step + +def RK4(xx_step, xx, vv, alpha, mm, target, epsilon): + #Runge-Kutta RK4 + diff = target - xx[-1] + #if diff < 0: + + if diff >= 0: + while xx[-1] <= target: + if (np.abs(xx[-1] - vv[-1] - 1.0) > epsilon): + vv_step, alpha_step = RK4_step(vv, xx, alpha, xx_step) + print( vv_step, alpha_step) + else: + vv_step = vv[-1] + alpha_step = alpha[-1] + print("PIIP") + + #print(np.abs(xx[-1] - vv[-1]), epsilon) + + xx = np.append(xx, xx[-1]+xx_step) + alpha = np.append(alpha, alpha_step) + vv = np.append(vv, vv_step) + mm_step = get_m(xx[-1], vv[-1], alpha[-1]) + mm = np.append(mm, mm_step) + else: + while xx[-1] >= target: + if (np.abs(xx[-1] - vv[-1] - 1.0) > epsilon): + vv_step, alpha_step = RK4_step(vv, xx, alpha, xx_step) + print( vv_step, alpha_step) + else: + vv_step = vv[-1] + alpha_step = alpha[-1] + print("PIIP") + + #print(np.abs(xx[-1] - vv[-1]), epsilon) + + xx = np.append(xx, xx[-1]+xx_step) + alpha = np.append(alpha, alpha_step) + vv = np.append(vv, vv_step) + mm_step = get_m(xx[-1], vv[-1], alpha[-1]) + mm = np.append(mm, mm_step) + + + return xx, vv, alpha, mm + +# From Shu 1977 TABLE II + +xx_SHU = np.array([0.05 , 0.10 , 0.15 , 0.20 , 0.25 , 0.30 , 0.35 , 0.40 , 0.45 , + 0.50 , 0.55 , 0.60 , 0.65 , 0.70 , 0.75 , 0.80 , 0.85 , + 0.90 , 0.95 , 1.00]) +alpha_SHU = np.array([71.5 , 27.8 , 16.4 , 11.5 , 8.76 , 7.09 , 5.95 , 5.14 , 4.52 , + 4.04 , 3.66 , 3.35 , 3.08 , 2.86 , 2.67 , 2.50 , 2.35 , + 2.22 , 2.10 , 2.00]) +vv_SHU = -np.array([5.44 , 3.47 , 2.58 , 2.05 , 1.68 , 1.40 , 1.18 , 1.01 , 0.861, + 0.735, 0.625, 0.528, 0.442, 0.363, 0.291, 0.225, 0.163, + 0.106, 0.051, 0.00]) +mm_SHU = np.array([0.981, 0.993, 1.01 , 1.03 , 1.05 , 1.08 , 1.12 , 1.16 , 1.20 , + 1.25 , 1.30 , 1.36 , 1.42 , 1.49 , 1.56 , 1.64 , 1.72 , + 1.81 , 1.90 , 2.00]) + + +##From Shu (1977) +#AA = [ 2.0, 2.2, 2.4, 2.6, 2.8, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0] +#m0 = [0.975, 1.45, 1.88, 2.31, 2.74, 3.18, 3.63, 4.10, 4.58, 5.08, 5.58] +#AA = np.array(AA) +#m0 = np.array(m0) + +#xx0 = xx_SHU[1] +#alpha0 = alpha_SHU[1] +#vv0 = vv_SHU[1] +#xx_step = 0.005 +#target = 1.0 + +xx0 = xx_SHU[-3] +alpha0 = alpha_SHU[-3] +vv0 = vv_SHU[-3] +target = 0.05 +xx_step = -0.005 +xx_step = -0.001 + +print(get_m(xx0, alpha0, vv0)) + +xx = np.array([]) +alpha = np.array([]) +vv = np.array([]) +mm = np.array([]) + +xx = np.append(xx, xx0) +alpha = np.append(alpha, alpha0) +vv = np.append(vv, vv0) +mm = np.append(mm, get_m(xx0, alpha0, vv0)) + +print(xx, alpha, vv, mm) + + +xx_EUL, vv_EUL, alpha_EUL, mm_EUL = euler(xx_step, xx, vv, alpha, mm, target) +xx_RK , vv_RK , alpha_RK , mm_RK = RK4(xx_step, xx, vv, alpha, mm, target, epsilon = 0.000001) + +mm_EUL = get_m(xx_EUL, alpha_EUL, vv_EUL) +mm_RK = get_m(xx_RK , alpha_RK , vv_RK ) +mm_SHU = get_m(xx_SHU, alpha_SHU, vv_SHU) + +# Plotting time + +figQ, axQ = plt.subplots(nrows=2, ncols=2, sharex=True) + +axQ[0,0].plot(xx_EUL, alpha_EUL, label=r'$\alpha$ (Euler)', linewidth = 3.0) +axQ[0,0].plot(xx_RK , alpha_RK , label=r'$\alpha$ (RK4)', linewidth = 3.0) +axQ[0,0].plot(xx_SHU, alpha_SHU, 'd', label=r'$\alpha$ (Shu)', linewidth = 3.0) +axQ[0,0].set_xlabel(r'x') +axQ[0,0].set_ylabel(r'$\alpha$') +axQ[0,0].legend() + +axQ[0,1].plot(xx_EUL, np.abs(vv_EUL), label='v (Euler)', linewidth = 3.0) +axQ[0,1].plot(xx_RK , np.abs(vv_RK ), label='v (RK4)', linewidth = 3.0) +axQ[0,1].plot(xx_SHU, np.abs(vv_SHU),'d', label='v (Shu)', linewidth = 3.0) +axQ[0,1].set_xlabel(r'x') +axQ[0,1].set_ylabel(r'-v') +axQ[0,1].legend() + +axQ[1,0].plot(xx_EUL, mm_EUL, label='m (Euler)', linewidth = 3.0) +axQ[1,0].plot(xx_RK , mm_RK , label='m (RK4)', linewidth = 3.0) +axQ[1,0].plot(xx_SHU , mm_SHU , 'd', label='m (Shu)', linewidth = 3.0) +axQ[1,0].set_xlabel(r'x') +axQ[1,0].set_ylabel(r'm') +axQ[1,0].legend() + + +axQ[1,1].plot(xx_EUL, xx_EUL-vv_EUL, label='x-v (Euler)', linewidth = 3.0) +axQ[1,1].plot(xx_RK , xx_RK -vv_RK , label='x-v (RK4)', linewidth = 3.0) +axQ[1,1].plot(xx_SHU, xx_SHU-vv_SHU, 'd', label='x-v (Shu)', linewidth = 3.0) +axQ[1,1].set_xlabel(r'x') +axQ[1,1].set_ylabel(r'x-v') +axQ[1,1].legend() + +# Time to convert to physical quantities +yr = 3.154e+7 #s +kyr = 1000.0*yr +km = 1e5 #cm +AU = 1.496e+13 #cm +Msun = 1.98847e33 #g + +cs0 = 20000 #cs cm/s "a" in Shu notation + +tt_list = np.linspace(10*kyr, 20.0*kyr, num=4) +mm = get_m(xx_RK, vv_RK, alpha_RK) + + +fig, ax = plt.subplots(nrows=1, ncols=3, sharex=True) + +for tt in tt_list: + rho = alpha_to_rho(alpha_RK, tt) + RR = xx_RK*(cs0*tt) + time = r'%.2f $\mathrm{kyr}$' % (tt/kyr) + + ax[0].plot(RR/AU, rho, label= r'$\rho$, t = ' + time, linewidth = 3.0) + ax[0].set_xlabel(r'R (AU)') + ax[0].set_ylabel(r'$\rho$ (g/cm$^3$)') + ax[0].set_xscale('log') + ax[0].set_yscale('log') + ax[0].legend() + + uu = vv_to_uu(vv_RK, cs0) + + ax[1].plot(RR/AU, -uu/km, label= r'$u$, t = ' + time, linewidth = 3.0) + ax[1].set_xlabel(r'R (AU)') + ax[1].set_ylabel(r'-$u$ (km/s)') + ax[1].set_yscale('log') + ax[1].legend() + + MM = mm_to_MM(mm, tt, cs0) + + ax[2].plot(RR/AU, MM/Msun, label= r'$M$, t = ' + time, linewidth = 3.0) + ax[2].set_xlabel(r'R (AU)') + ax[2].set_ylabel(r'$M$ ($M_\odot}$)') + ax[2].legend() + + + +plt.show() + + + + diff --git a/analysis/python/purgepng.sh b/analysis/python/purgepng.sh new file mode 100755 index 0000000..8723972 --- /dev/null +++ b/analysis/python/purgepng.sh @@ -0,0 +1 @@ +rm *.png diff --git a/analysis/python/samples/README.md b/analysis/python/samples/README.md new file mode 100644 index 0000000..bed7a71 --- /dev/null +++ b/analysis/python/samples/README.md @@ -0,0 +1,3 @@ +# Analysis script samples + +This directory is for sample scripts useable for data analysis and visualization. diff --git a/analysis/python/samples/lnrhobound.py b/analysis/python/samples/lnrhobound.py new file mode 100644 index 0000000..2400bad --- /dev/null +++ b/analysis/python/samples/lnrhobound.py @@ -0,0 +1,41 @@ +import pylab as plt +import numpy as np + + +def do_bound(coeff): + vertex_buffer = np.zeros(7, dtype=np.float32) + xx = np.arange(vertex_buffer.size) + + edge_idx = 3 + + for dst_idx in range(3): + i_diff = abs(edge_idx - dst_idx) + vertex_buffer[dst_idx] = coeff*np.exp(vertex_buffer[edge_idx]) + + print("initial",vertex_buffer) + + for i in range(i_diff): + vertex_buffer[dst_idx] = coeff*vertex_buffer[dst_idx] + print("looped", vertex_buffer[dst_idx]) + + vertex_buffer[dst_idx] = np.log(vertex_buffer[dst_idx]); + print("final",vertex_buffer) + + return xx, vertex_buffer + + +AC_dsx = 0.04908738521 +coeff1 = 1.0 - AC_dsx/(25.0*AC_dsx) +coeff2 = 1.0 - AC_dsx/(100.0*AC_dsx) + + +plt.figure() +xx, yy = do_bound(coeff1) +plt.plot(xx, yy) + +plt.figure() +xx, yy = do_bound(coeff2) +plt.plot(xx, yy) + +plt.show() + diff --git a/analysis/python/samples/readtest.py b/analysis/python/samples/readtest.py new file mode 100644 index 0000000..ad1d0b1 --- /dev/null +++ b/analysis/python/samples/readtest.py @@ -0,0 +1,260 @@ +''' + Copyright (C) 2014-2019, Johannes Pekkilae, Miikka Vaeisalae. + + This file is part of Astaroth. + + Astaroth is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Astaroth is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Astaroth. If not, see . +''' +import astar.data as ad +import astar.visual as vis +import pylab as plt +import numpy as np +import sys + +##mesh = ad.read.Mesh(500, fdir="/tiara/home/mvaisala/astaroth-code/astaroth_2.0/build/") +## +##print(np.shape(mesh.uu)) +##print(np.shape(mesh.lnrho)) +## +##uu_tot = np.sqrt(mesh.uu[0]**2.0 + mesh.uu[1]**2.0 + mesh.uu[2]**2.0) +##vis.slices.plot_3(mesh, uu_tot, title = r'$|u|$', bitmap = True, fname = 'uutot') +## +##vis.slices.plot_3(mesh, mesh.lnrho, title = r'$\ln \rho$', bitmap = True, fname = 'lnrho') +## +##print(mesh.minfo.contents) + + +AC_unit_density = 1e-17 +AC_unit_velocity = 1e5 +AC_unit_length = 1.496e+13 + + +print("sys.argv", sys.argv) + +#meshdir = "/tiara/home/mvaisala/astaroth-code/astaroth_2.0/build/" +meshdir = "/tiara/ara/data/mvaisala/tmp/astaroth-code/astaroth_2.0/build/" +#meshdir = "/tiara/ara/data/mvaisala/asth_testbed_double/" + +if "xtopbound" in sys.argv: + for i in range(0, 171): + mesh = ad.read.Mesh(i, fdir=meshdir) + if mesh.ok: + np.set_printoptions(precision=4, linewidth=150) + uu_tot = np.sqrt(mesh.uu[0]**2.0 + mesh.uu[1]**2.0 + mesh.uu[2]**2.0) + print(mesh.lnrho.shape) + print(range((mesh.lnrho.shape[0]-7),mesh.lnrho.shape[0])) + print('lnrho', i, mesh.lnrho[(mesh.lnrho.shape[0]-7):mesh.lnrho.shape[0], 20, 100]) + print('uux', i, mesh.uu[0][(mesh.lnrho.shape[0]-7):mesh.lnrho.shape[0], 20, 100]) + print('uuy', i, mesh.uu[1][(mesh.lnrho.shape[0]-7):mesh.lnrho.shape[0], 20, 100]) + print('uuz', i, mesh.uu[2][(mesh.lnrho.shape[0]-7):mesh.lnrho.shape[0], 20, 100]) + print('uu_tot', i, uu_tot[ (mesh.lnrho.shape[0]-7):mesh.lnrho.shape[0], 20, 100]) + + +if "single" in sys.argv: + mesh = ad.read.Mesh(1, fdir=meshdir) + print(mesh.lnrho.shape) + + print( mesh.lnrho[1, 50, 100], 0.0) + print( mesh.lnrho[197, 50, 100], 0.0) + print( mesh.lnrho[100, 50, 1], 0.0) + print( mesh.lnrho[100, 50, 197], 0.0) + print( mesh.lnrho[100, 1, 100], "periodic") + print( mesh.lnrho[100, 101, 00], "periodic") + + angle = 0.78 + UUXX = -0.25 * np.cos(angle) + zorig = 4.85965 + zz = [0.0490874*1.0 - zorig, 0.0490874*100.0 - zorig, 0.0490874*197.0 - zorig] + print (zz) + zz = np.array(zz) + UUZZ = - 0.25*np.sin(angle)*np.tanh(zz/0.2) + #plt.plot(np.linspace(-5.0, 5.0, num=100),- (0.25*np.sin(angle))*np.tanh(np.linspace(-5.0, 5.0, num=100)/0.2)) + #plt.show() + print("---- UUX") + print( mesh.uu[0][1, 50, 100], 0.0) + print( mesh.uu[0][197, 50, 100], UUXX) + print( mesh.uu[0][100, 50, 1], UUXX) + print( mesh.uu[0][100, 50, 197], UUXX) + print( mesh.uu[0][100, 1, 100], "periodic") + print( mesh.uu[0][100, 101, 00], "periodic") + print("---- UUY") + print( mesh.uu[1][1, 50, 100], 0.0) + print( mesh.uu[1][197, 50, 100], 0.0) + print( mesh.uu[1][100, 50, 1], 0.0) + print( mesh.uu[1][100, 50, 197], 0.0) + print( mesh.uu[1][100, 1, 100], "periodic") + print( mesh.uu[1][100, 101, 00], "periodic") + print("---- UUZ") + print( mesh.uu[2][1, 50, 100], 0.0) + print( mesh.uu[2][197, 50, 100], UUZZ[1]) + print( mesh.uu[2][100, 50, 1], UUZZ[0]) + print( mesh.uu[2][100, 50, 197], UUZZ[2]) + print( mesh.uu[2][100, 1, 100], "periodic") + print( mesh.uu[2][100, 101, 00], "periodic") + +if 'xline' in sys.argv: + mesh = ad.read.Mesh(0, fdir=meshdir) + plt.figure() + plt.plot(mesh.uu[0][100, 50, :] , label="z") + plt.plot(mesh.uu[0][100, :, 100], label="x") + plt.plot(mesh.uu[0][:, 50, 100] , label="y") + plt.legend() + + plt.figure() + plt.plot(mesh.uu[0][197, 50, :] , label="z edge") + + plt.figure() + plt.plot(mesh.uu[1][100, 50, :] , label="z") + plt.plot(mesh.uu[1][100, :, 100], label="x") + plt.plot(mesh.uu[1][:, 50, 100] , label="y") + plt.legend() + + plt.figure() + plt.plot(mesh.uu[2][100, 50, :] , label="z") + plt.plot(mesh.uu[2][100, :, 100], label="x") + plt.plot(mesh.uu[2][:, 50, 100] , label="y") + plt.legend() + plt.show() + +if 'check' in sys.argv: + mesh = ad.read.Mesh(0, fdir=meshdir) + vis.slices.plot_3(mesh, mesh.lnrho, title = r'$\ln \rho$', bitmap = False, fname = 'lnrho', contourplot = True) + plt.show() + + + +if 'diff' in sys.argv: + mesh0 = ad.read.Mesh(1, fdir=meshdir) + mesh1 = ad.read.Mesh(2, fdir=meshdir) + vis.slices.plot_3(mesh1, mesh1.lnrho - mesh0.lnrho, title = r'$\ln \rho$', bitmap = True, fname = 'lnrho') + vis.slices.plot_3(mesh1, mesh1.uu[0] - mesh0.uu[0], title = r'$u_x$', bitmap = True, fname = 'uux') + vis.slices.plot_3(mesh1, mesh1.uu[1] - mesh0.uu[1], title = r'$u_y$', bitmap = True, fname = 'uuy') + vis.slices.plot_3(mesh1, mesh1.uu[2] - mesh0.uu[2], title = r'$u_z$', bitmap = True, fname = 'uuz') + +if '1d' in sys.argv: + plt.figure() + for i in range(0, 100001, 1000): + mesh = ad.read.Mesh(i, fdir=meshdir) + if mesh.ok: + + if 'lnrho' in sys.argv: + plt.plot(mesh.lnrho[:, 20, 100], label=i) + elif 'uux' in sys.argv: + plt.plot(mesh.uu[0][:, 20, 100], label=i) + elif 'uuy' in sys.argv: + plt.plot(mesh.uu[1][:, 20, 100], label=i) + elif 'uuz' in sys.argv: + plt.plot(mesh.uu[2][:, 20, 100], label=i) + elif 'uutot' in sys.argv: + uu_tot = np.sqrt(mesh.uu[0]**2.0 + mesh.uu[1]**2.0 + mesh.uu[2]**2.0) + plt.plot(uu_tot[:, 20, 100], label=i) + + plt.legend() + + plt.show() + + +if 'sl' in sys.argv: + maxfiles = 200002 + stride = 10000 + for i in range(0, maxfiles, stride): + mesh = ad.read.Mesh(i, fdir=meshdir) + print(" %i / %i" % (i, maxfiles)) + if mesh.ok: + uu_tot = np.sqrt(mesh.uu[0]**2.0 + mesh.uu[1]**2.0 + mesh.uu[2]**2.0) + + if 'lim' in sys.argv: + vis.slices.plot_3(mesh, mesh.lnrho, title = r'$\ln \rho$', bitmap = True, fname = 'lnrho', colrange=[-0.02, 0.0]) + vis.slices.plot_3(mesh, np.exp(mesh.lnrho), title = r'$\rho$', bitmap = True, fname = 'rho', colrange=[0.97, 1.0]) + vis.slices.plot_3(mesh, mesh.uu[0], title = r'$u_x$', bitmap = True, fname = 'uux', colrange=[-0.002, 0.002]) + vis.slices.plot_3(mesh, mesh.uu[1], title = r'$u_y$', bitmap = True, fname = 'uuy', colrange=[-1.0e-20, 1.0e-20]) + vis.slices.plot_3(mesh, mesh.uu[2], title = r'$u_z$', bitmap = True, fname = 'uuz', colrange=[-0.002, 0.002]) + vis.slices.plot_3(mesh, np.exp(mesh.lnrho), title = r'$N_\mathrm{col}$', bitmap = True, fname = 'colden', slicetype = 'sum', colrange=[0.0, 100.0]) + vis.slices.plot_3(mesh, uu_tot, title = r'$|u|$', bitmap = True, fname = 'uutot', colrange=[0.00, 0.004]) + else: + vis.slices.plot_3(mesh, mesh.lnrho, title = r'$\ln \rho$', bitmap = True, fname = 'lnrho') + vis.slices.plot_3(mesh, np.exp(mesh.lnrho), title = r'$\rho$', bitmap = True, fname = 'rho') + #vis.slices.plot_3(mesh, mesh.ss, title = r'$s$', bitmap = True, fname = 'ss') + vis.slices.plot_3(mesh, mesh.uu[0], title = r'$u_x$', bitmap = True, fname = 'uux') + vis.slices.plot_3(mesh, mesh.uu[1], title = r'$u_y$', bitmap = True, fname = 'uuy') + vis.slices.plot_3(mesh, mesh.uu[2], title = r'$u_z$', bitmap = True, fname = 'uuz') + vis.slices.plot_3(mesh, np.exp(mesh.lnrho), title = r'$N_\mathrm{col}$', bitmap = True, fname = 'colden', slicetype = 'sum') + vis.slices.plot_3(mesh, uu_tot, title = r'$|u|$', bitmap = True, fname = 'uutot') + + + +if 'ts' in sys.argv: + ts = ad.read.TimeSeries(fdir=meshdir) + + end_rm = -1 #-35#-40 + + plt.figure() + xaxis = 't_step' + yaxis1 = 'lnrho_rms' + yaxis2 = 'lnrho_min' + yaxis3 = 'lnrho_max' + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3) + plt.xlabel(xaxis) + plt.legend() + + plt.figure() + xaxis = 't_step' + yaxis1 = 'uutot_rms' + yaxis2 = 'uutot_min' + yaxis3 = 'uutot_max' + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3) + plt.xlabel(xaxis) + plt.legend() + + plt.figure() + xaxis = 't_step' + yaxis1 = 'uux_rms' + yaxis2 = 'uux_min' + yaxis3 = 'uux_max' + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3) + plt.xlabel(xaxis) + plt.legend() + + plt.figure() + xaxis = 't_step' + yaxis1 = 'uuy_rms' + yaxis2 = 'uuy_min' + yaxis3 = 'uuy_max' + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3) + plt.xlabel(xaxis) + plt.legend() + + plt.figure() + xaxis = 't_step' + yaxis1 = 'uuz_rms' + yaxis2 = 'uuz_min' + yaxis3 = 'uuz_max' + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis1][:end_rm], label=yaxis1) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis2][:end_rm], label=yaxis2) + plt.plot(ts.var[xaxis][:end_rm], ts.var[yaxis3][:end_rm], label=yaxis3) + plt.xlabel(xaxis) + plt.legend() + + + plt.show() + + diff --git a/config/astaroth.conf b/config/astaroth.conf new file mode 100644 index 0000000..5100bf6 --- /dev/null +++ b/config/astaroth.conf @@ -0,0 +1,54 @@ + + +/* + * ============================================================================= + * "Compile-time" params + * ============================================================================= + */ +AC_nx = 192 +AC_ny = 120 +AC_nz = 7 + +AC_dsx = 0.04908738521 +AC_dsy = 0.04908738521 +AC_dsz = 0.04908738521 + +/* + * ============================================================================= + * Run-time params + * ============================================================================= + */ +AC_max_steps = 1001 +AC_save_steps = 10 +AC_bin_steps = 1000 +AC_bin_save_t = 1e666 + +// Hydro +AC_cdt = 0.4 +AC_cdtv = 0.3 +AC_cdts = 1.0 +AC_nu_visc = 5e-3 +AC_cs_sound = 1.0 +AC_zeta = 0.01 + +// Magnetic +AC_eta = 5e-3 +AC_mu0 = 1.4 +AC_chi = 0.0001 + +// Forcing +AC_relhel = 0.0 + +// Entropy +AC_cp_sound = 1.0 +AC_gamma = 0.5 +AC_lnT0 = 1.2 +AC_lnrho0 = 1.3 + +/* + * ============================================================================= + * Initial conditions + * ============================================================================= + */ +AC_ampl_lnrho = 0.0 +AC_ampl_uu = 1.0 diff --git a/config/astaroth_pseudodisk.conf b/config/astaroth_pseudodisk.conf new file mode 100644 index 0000000..4cfde41 --- /dev/null +++ b/config/astaroth_pseudodisk.conf @@ -0,0 +1,121 @@ + + +/* + * ============================================================================= + * "Compile-time" params + * ============================================================================= + */ +AC_nx = 192 +AC_ny = 48 +AC_nz = 192 + +AC_dsx = 0.04908738521 +AC_dsy = 0.04908738521 +AC_dsz = 0.04908738521 + +/* + * ============================================================================= + * Run-time params + * ============================================================================= + */ +//AC_max_steps = 16001 +//AC_save_steps = 50 +//AC_bin_steps = 16000 + +//AC_max_steps = 1001 +//AC_save_steps = 10 +//AC_bin_steps = 1000 + +//AC_max_steps = 11 +//AC_save_steps = 1 +//AC_bin_steps = 1 + +//AC_max_steps = 4 +//AC_save_steps = 1 +//AC_bin_steps = 1 + +//AC_max_steps = 1201 +//AC_save_steps = 10 +//AC_bin_steps = 1200 +//AC_bin_save_t = 5.0 + + +//AC_max_steps = 50001 +//AC_save_steps = 100 +//AC_bin_steps = 10000 + +AC_max_steps = 100001 +AC_save_steps = 500 +AC_bin_steps = 20000 + +AC_bin_save_t = 2300000.0 + +// Hydro +AC_cdt = 0.4 +AC_cdtv = 0.3 +AC_cdts = 1.0 +//GOOD VISC Re_mesh = 3 +//AC_nu_visc = 3.0e-3 +AC_nu_visc = 1.0e-3 +AC_cs_sound = 0.2 +AC_zeta = 1.0e-3 + +// Magnetic +AC_eta = 5e-3 +AC_mu0 = 1.4 +AC_chi = 0.0001 + +// Forcing +AC_relhel = 0.0 + +// Entropy +// cp arbitrary +AC_cp_sound = 1.0 +// 5/3 adiabatic process +AC_gamma = 1.66 +AC_lnT0 = 1.0 +AC_lnrho0 = 0.0 + + +// Boundary condition. Defined by arbitrary int. +AC_bc_type = 666 +//AC_bc_type = 121 +AC_trans = 0.6 + + +//Physical units (cgs) +// Based on Shu 1977 model calculations with t = 20 kyr, R = 500 AU +// g/cm^3 +AC_unit_density = 1e-17 +// cm/s +// Now 1 km/s +//AC_unit_velocity = 1e5 +AC_unit_velocity = 1.0 +// cm +// Now 1 AU +AC_unit_length = 1.496e+13 + +//Properties of gravitating star* +AC_star_pos_x = -500.0 +//AC_star_pos_x = -10.0 +AC_star_pos_y = 0.0 +AC_star_pos_z = 0.0 +//In M_sun +//AC_M_star = 0.05 +AC_M_star = 0.5 +//AC_M_star = 0.0 + +/* + * ============================================================================= + * Initial conditions + * ============================================================================= + */ +AC_ampl_lnrho = 0.0 +AC_lnrho_edge = -1.0 +AC_lnrho_out = 0.0 +//original +//AC_ampl_uu = 0.25 +//For gravity test +AC_ampl_uu = 0.0 +AC_angl_uu = 0.0 +//AC_angl_uu = 0.35 diff --git a/doc/doxygen/.gitignore b/doc/doxygen/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/doc/doxygen/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/doc/manual/manual.md b/doc/manual/manual.md new file mode 100644 index 0000000..007b1bc --- /dev/null +++ b/doc/manual/manual.md @@ -0,0 +1,131 @@ + +*Miikka Vaisala: This is just something I have astarted to write up to make sense about the Astaroth 2.0. Starting for personally important notes to understand the code. Will be refined as my understanding improves.* + +#Astaroth manual + +## Compilation + +See the `README.md`. At the moment, let us keep certaint things in one place. + +## Simulation instructions + +At the moment it is only possible to build and run in the `astaroth_2.0/build/` directory. Possibility to add separate run directories will be included later. + +### Choosing physics + +Runtime settings can be adjusted from `astaroth_2.0/include/astaroth.h` and `astaroth_2.0/config/astaroth.conf`. + +Howeve, physics switches LENTROPY, LFORCING etc. do not work at the moment. There has been an issue to get pre-processor combatible with astaroth-domain-specific language in Astaroth 2.0. Therefore, all features are online by default. + +To get the switcher working now, rename `astaroth_2.0/src/core/kernels/rk3handtuned.cuh` -> `rk3.cuh`. (**MV:** Not yet tested.) + +How to use? + +What kind of runtime settings? + +### Setting initial conditions + +Where can we effectively choose the initial condition? + +### Launchin a run + +`./ac_run -s` assuming you are doing a normal simulation. Basic code for this invocation can be found in the source file `astaroth_2.0/src/standalone/simulation.cc`. + +Please note that launching `./ac_run -t` will *fail if entropy and forcing are in use*. Test is mainly for finding paralleization bugs. (In principle if hydro stuff and induction work, so will forcing and entropy.) + +### Diagnostic variables + +What is calculated? + +Where it is saved? + +### Simulation data + +Saving output binaries is not enabled yet. + +**MV:** I am planning to implement HDF5 format for the data. **TOP PRIORITY**. + +#### Notes about data structures + +- Configuration parameters have prefix `AC_`, such as `AC_dsx`. + +- All configurations are stored in the struct `AcMeshInfo`, containing tables `int_params` ja `real_params`. **NOTE:** `int_params` and `real_params` require diligence. If you call e.g. `int_params[AC_dsx]`, the result will be something unexpected. So-far error checking with this has now been possible to be automated. + + +- All mesh data is stored to the struct `AcMesh`, containing both configuration values and vertex data (`lnrho`, `uux`, etc.) + +- All essential tructs, macros and enumerators are found in astaroth.h for better reference. + +- In the case there is changes in the data layout, better use macro `AC_VTXBUF_IDX(i, j, k, mesh_info)`which transform indices from 3D to 1D. Therefore no need to start writing `i + j * mesh_info.int_params[AC_mx] + ...` which would affect the code readability. + +- AcReal on generic floating point real number type used everywhere in the code. Currently can be either `float` or `double`. Possibly in the future also `half` or `long double` could become available. + +Sample code: + +```cpp +AcMeshInfo mesh_info; +// Loads data from astaroth.conf into the AcMeshInfo struct +load_config(&mesh_info); + +// Allocates data on the host for the AcMesh struct using information found in mesh_info. +AcMesh* mesh = acmesh_create(mesh_info); + +// Initializes mesh to InitType (specified in standalone/model/host_memory.h) +acmesh_init_to(INIT_TYPE_GAUSSIAN_RADIAL_EXPL, mesh); + +// Allocates data on the device for the AcMesh struct +acInit(mesh_info); + +acLoad(*mesh); // Loads the mesh to the device + + +const AcReal dt = 1.f; + +// Synchronizes previous device commands +acSynchronize(); + +// Does a full rk3 integration step on the device +acIntegrate(dt); + +acSynchronize(); + +// Store data from device to host mesh +acStore(mesh); + +printf("nx: %d, dsx %f\n", + mesh->info.int_params[AC_nx], + double(mesh->info.real_params[AC_dsx])); +printf("First vertex of the computational domain: %f\n", +double(mesh->vertex_buffer[VTXBUF_LNRHO][AC_VTXBUF_IDX(3, 3, 3, mesh_info)])); + +``` + + +### Reading data + +Depends on the output format. With HDF5 should be simple enough. + +[Jupyter notebook](http://jupyter.org/) visualization? + +Do we want to use [YT?](https://yt-project.org/) + +### Live rendering + +MV: Cool, but does not work for remote cluster so far. A GPU workstation is required. + +##Multi-GPU + +At the moment multi-GPU is not included in Astaroth 2.0. However, it has been implemented 1.0 (`astaroth_1.0/src/gpu/cuda/cuda_generic.cu`) could be essentially ported by copypasting to `astaroth_2.0/src/core/astaroth.cu` after we have clear idea how to run things with single GPU. Could be done overnight in principle. + + +## Profiling + +The built-in beachmark is currently unreliable due to an unknown reason. Please use [nvprof and nvvp](https://docs.nvidia.com/cuda/profiler-users-guide/index.html) for precise profiling. Also, NVIDIA suggests their [Nsight Systems](https://developer.nvidia.com/nsight-systems). + + + +## ETC + +**Note** `auto_optimize.sh` does not currently work, but it aims to tune thread block dimensions automatically. + + diff --git a/doxyfile b/doxyfile new file mode 100644 index 0000000..7bab478 --- /dev/null +++ b/doxyfile @@ -0,0 +1,2427 @@ +# Doxyfile 1.8.11 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "Astaroth" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = cu=c++ cuh=c++ + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = doc/doxygen/doxygen_warnings.log + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = src include + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, +# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. + +FILE_PATTERNS = *.cc *.h *.cu *.cuh + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse-libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = doc/doxygen/astaroth_doc_html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /