#include <complex.h>
#include <fftw3.h>
#include "crusde_api.h"
#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
Defines | |
#define | RESET(x, y) (x = y = -1) |
#define | POSITION(m, n) (n+(N_Y)*m) |
Functions | |
void | register_output_fields () |
void | register_parameter () |
Register parameters this Kernel claims from the input. | |
void | request_plugins () |
void | init () |
Initialization of the convolution. Allocation of memory for inputs and outputs. | |
void | clear () |
void | run () |
Performs the fast convolution. | |
const char * | get_name () |
const char * | get_version () |
const char * | get_authors () |
const char * | get_description () |
PluginCategory | get_category () |
Variables | |
double * | decay_in |
double * | history_in |
double * | conv_out |
double ** | spatial_result |
fftw_complex * | decay_out |
fftw_complex * | history_out |
fftw_complex * | conv_in |
fftw_plan | decay_plan |
fftw_plan | history_plan |
fftw_plan | conv_plan |
double ** | result |
int | N_T |
int | size_T = 0 |
int | size_X = 0 |
int | size_Y = 0 |
int | x = -1 |
int | y = -1 |
int | i = 0 |
int | n = -1 |
unsigned long int | t = 0 |
int | dimensions = 1 |
int | displacement_dimensions = 1 |
boolean | is_initialized = false |
void(* | fast_spatial_conv )() = NULL |
Implements a fast convolution using the Fast Fourier Transform (DFT). This Plugin depends on the FFTW3 library, http://www.fftw3.org , which is used to allow convolution in the spectral domain (see convolution theorem).
void clear | ( | ) |
Frees memory allocated during init(). FFTW plans are destroyed.
References conv_in, conv_out, conv_plan, decay_in, decay_out, decay_plan, dimensions, history_in, history_out, history_plan, is_initialized, n, and result.
const char* get_authors | ( | ) |
PluginCategory get_category | ( | ) |
References KERNEL_PLUGIN.
const char* get_description | ( | ) |
const char* get_name | ( | ) |
const char* get_version | ( | ) |
void init | ( | ) |
Initialization of the convolution. Allocation of memory for inputs and outputs.
The field sizes are adjusted according to the needs to avoid wrap around effects in the spectal domain and allow for effective use of DFT (lenght and width are a power of 2). Memory is allocated using fftw_malloc for DFT inputs and outputs (load_in, load_out, green_in, green_out, conv_in, conv_out). Three FFTW plans are created for DFT transform of Green and load arrays and IDFT of the convolution result back to original domain.
References conv_in, conv_out, conv_plan, crusde_get_dimensions(), crusde_get_displacement_dimensions(), crusde_get_size_x(), crusde_get_size_y(), crusde_get_timesteps(), decay_in, decay_out, decay_plan, dimensions, displacement_dimensions, history_in, history_out, history_plan, i, is_initialized, n, N_T, result, size_T, size_X, size_Y, and x.
void register_output_fields | ( | ) |
empty
void register_parameter | ( | ) |
Register parameters this Kernel claims from the input.
This plugin calls register_kernel_param() defined in crusde_api.h to register references to parameters this Kernel will need to operate properly. For command line use the order of registration in this function defines the identification of parameters in the command line string (i.e. './green -KfirstRegistered/secondRegistered/...'). In case an XML is used to configure the experiment, the reference to this parameter will be identified by the string passed as second argument to register_kernel_param().
This function registers the references in the following order:
Thus, the command line parameter string is: -K
void request_plugins | ( | ) |
we re-use spatial convolution!
References crusde_request_kernel_plugin(), and fast_spatial_conv.
void run | ( | ) |
Performs the fast convolution.
Requests values for each point in the examined area from Green's function (only once when modeltime == 0) and load function (every timestep). Does the origin shifting necessary for the Green's function values. The Green's function values are requested for each displacement direction the Green's function registered with the CrusDe.
FFTW plan is executed for the load. Then for each Green's function displacement direction the FFTW plan is executed, a complex multiplication of the DFT results performed and then for product the FFTW plan is executed (IDFT). The result of the convolution is extracted from the oversized IDFT result and cropped to the original size of the examined region.
ATTN: result[d][x] still holds the values from the last time run was called. This way adding up the results of multiple jobs is realized!
References conv_in, conv_out, conv_plan, crusde_crustal_decay_given(), crusde_debug(), crusde_get_crustal_decay_at(), crusde_get_load_history_at(), crusde_get_number_of_loads(), crusde_get_result(), crusde_load_history_given(), crusde_model_time(), crusde_set_current_load_component(), d, decay_in, decay_out, decay_plan, displacement_dimensions, fast_spatial_conv, history_in, history_out, history_plan, i, n, N_T, RESET, result, size_T, size_X, size_Y, spatial_result, t, x, and y.
fftw_complex * conv_in |
double * conv_out |
fftw_plan conv_plan |
fftw_plan decay_plan |
int dimensions = 1 |
int displacement_dimensions = 1 |
void(* fast_spatial_conv)() = NULL |
Referenced by request_plugins(), and run().
double * history_in |
fftw_complex * history_out |
fftw_plan history_plan |
int i = 0 |
boolean is_initialized = false |
int n = -1 |
double** result |
double ** spatial_result |
Referenced by run().
unsigned long int t = 0 |
int x = -1 |
int y = -1 |