Skip to content
Snippets Groups Projects
Commit 9facd2ee authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'master' into radiated_energy

parents 55fd3914 e65279ac
Branches
Tags
1 merge request!247Radiated energy
...@@ -55,7 +55,7 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \ ...@@ -55,7 +55,7 @@ AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
runner_doiact_fft.c threadpool.c cooling.c runner_doiact_fft.c threadpool.c cooling.c
# Include files for distribution, not installation. # Include files for distribution, not installation.
nobase_noinst_HEADERS = approx_math.h atomic.h cycle.h error.h inline.h kernel_hydro.h kernel_gravity.h \ nobase_noinst_HEADERS = align.h approx_math.h atomic.h cycle.h error.h inline.h kernel_hydro.h kernel_gravity.h \
kernel_long_gravity.h vector.h runner_doiact.h runner_doiact_grav.h runner_doiact_fft.h \ kernel_long_gravity.h vector.h runner_doiact.h runner_doiact_grav.h runner_doiact_fft.h \
units.h intrinsics.h minmax.h kick.h timestep.h drift.h adiabatic_index.h io_properties.h \ units.h intrinsics.h minmax.h kick.h timestep.h drift.h adiabatic_index.h io_properties.h \
dimension.h equation_of_state.h \ dimension.h equation_of_state.h \
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_ALIGN_H
#define SWIFT_ALIGN_H
/**
* @brief Defines alignment of structures
*/
#define SWIFT_STRUCT_ALIGN __attribute__((aligned(32)))
#endif /* SWIFT_ALIGN_H */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stddef.h> #include <stddef.h>
/* Local includes. */ /* Local includes. */
#include "align.h"
#include "lock.h" #include "lock.h"
#include "multipole.h" #include "multipole.h"
#include "part.h" #include "part.h"
...@@ -44,7 +45,7 @@ struct space; ...@@ -44,7 +45,7 @@ struct space;
* The maximum was lowered by a further factor of 2 to be on the safe side.*/ * The maximum was lowered by a further factor of 2 to be on the safe side.*/
#define cell_max_tag (1 << 29) #define cell_max_tag (1 << 29)
#define cell_align 32 #define cell_align 128
/* Global variables. */ /* Global variables. */
extern int cell_next_tag; extern int cell_next_tag;
...@@ -74,7 +75,8 @@ struct pcell { ...@@ -74,7 +75,8 @@ struct pcell {
/* Relative indices of the cell's progeny. */ /* Relative indices of the cell's progeny. */
int progeny[8]; int progeny[8];
};
} SWIFT_STRUCT_ALIGN;
/* Structure to store the data of a single cell. */ /* Structure to store the data of a single cell. */
struct cell { struct cell {
...@@ -208,7 +210,7 @@ struct cell { ...@@ -208,7 +210,7 @@ struct cell {
#endif #endif
} __attribute__((aligned(cell_align))); } SWIFT_STRUCT_ALIGN;
/* Convert cell location to ID. */ /* Convert cell location to ID. */
#define cell_getid(cdim, i, j, k) \ #define cell_getid(cdim, i, j, k) \
......
...@@ -53,6 +53,6 @@ struct gpart { ...@@ -53,6 +53,6 @@ struct gpart {
which this gpart is linked. */ which this gpart is linked. */
long long id_or_neg_offset; long long id_or_neg_offset;
} __attribute__((aligned(gpart_align))); } SWIFT_STRUCT_ALIGN;
#endif /* SWIFT_DEFAULT_GRAVITY_PART_H */ #endif /* SWIFT_DEFAULT_GRAVITY_PART_H */
...@@ -38,7 +38,7 @@ struct xpart { ...@@ -38,7 +38,7 @@ struct xpart {
/* Old density. */ /* Old density. */
float omega; float omega;
} __attribute__((aligned(xpart_align))); } SWIFT_STRUCT_ALIGN;
/* Data of a single particle. */ /* Data of a single particle. */
struct part { struct part {
...@@ -125,6 +125,6 @@ struct part { ...@@ -125,6 +125,6 @@ struct part {
/* Pointer to corresponding gravity part. */ /* Pointer to corresponding gravity part. */
struct gpart* gpart; struct gpart* gpart;
} __attribute__((aligned(part_align))); } SWIFT_STRUCT_ALIGN;
#endif /* SWIFT_DEFAULT_HYDRO_PART_H */ #endif /* SWIFT_DEFAULT_HYDRO_PART_H */
...@@ -33,7 +33,7 @@ struct xpart { ...@@ -33,7 +33,7 @@ struct xpart {
/* Additional data used to record cooling information */ /* Additional data used to record cooling information */
struct cooling_xpart_data cooling_data; struct cooling_xpart_data cooling_data;
} __attribute__((aligned(xpart_align))); } SWIFT_STRUCT_ALIGN;
/* Data of a single particle. */ /* Data of a single particle. */
struct part { struct part {
......
...@@ -124,8 +124,8 @@ void hydro_write_particles(struct part* parts, struct io_props* list, ...@@ -124,8 +124,8 @@ void hydro_write_particles(struct part* parts, struct io_props* list,
UNIT_CONV_ACCELERATION, parts, a_hydro); UNIT_CONV_ACCELERATION, parts, a_hydro);
list[7] = io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts, list[7] = io_make_output_field("Density", FLOAT, 1, UNIT_CONV_DENSITY, parts,
primitives.rho); primitives.rho);
list[8] = io_make_output_field("Volume", FLOAT, 1, UNIT_CONV_VOLUME, parts, list[8] = io_make_output_field("Volume", FLOAT, 1, UNIT_CONV_INV_VOLUME,
geometry.volume); parts, geometry.volume);
list[9] = io_make_output_field("GradDensity", FLOAT, 3, UNIT_CONV_DENSITY, list[9] = io_make_output_field("GradDensity", FLOAT, 3, UNIT_CONV_DENSITY,
parts, primitives.gradients.rho); parts, primitives.gradients.rho);
list[10] = io_make_output_field_convert_part( list[10] = io_make_output_field_convert_part(
......
...@@ -33,7 +33,7 @@ struct xpart { ...@@ -33,7 +33,7 @@ struct xpart {
/* Additional data used to record cooling information */ /* Additional data used to record cooling information */
struct cooling_xpart_data cooling_data; struct cooling_xpart_data cooling_data;
} __attribute__((aligned(xpart_align))); } SWIFT_STRUCT_ALIGN;
/* Data of a single particle. */ /* Data of a single particle. */
struct part { struct part {
...@@ -204,5 +204,3 @@ struct part { ...@@ -204,5 +204,3 @@ struct part {
struct gpart *gpart; struct gpart *gpart;
} __attribute__((aligned(part_align))); } __attribute__((aligned(part_align)));
#endif /* SWIFT_GIZMO_HYDRO_PART_H */
...@@ -52,7 +52,7 @@ struct xpart { ...@@ -52,7 +52,7 @@ struct xpart {
struct cooling_xpart_data struct cooling_xpart_data
cooling_data; /*!< Additional data used to record cooling information */ cooling_data; /*!< Additional data used to record cooling information */
} __attribute__((aligned(xpart_align))); } SWIFT_STRUCT_ALIGN;
/** /**
* @brief Particle fields for the SPH particles * @brief Particle fields for the SPH particles
......
...@@ -31,12 +31,13 @@ ...@@ -31,12 +31,13 @@
#endif #endif
/* Local headers. */ /* Local headers. */
#include "align.h"
#include "const.h" #include "const.h"
/* Some constants. */ /* Some constants. */
#define part_align 64 #define part_align 128
#define xpart_align 32 #define xpart_align 128
#define gpart_align 32 #define gpart_align 128
/* Import the right hydro particle definition */ /* Import the right hydro particle definition */
#if defined(MINIMAL_SPH) #if defined(MINIMAL_SPH)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "../config.h" #include "../config.h"
/* Includes. */ /* Includes. */
#include "align.h"
#include "cell.h" #include "cell.h"
#include "cycle.h" #include "cycle.h"
...@@ -149,7 +150,7 @@ struct task { ...@@ -149,7 +150,7 @@ struct task {
/*! Is this task implicit (i.e. does not do anything) ? */ /*! Is this task implicit (i.e. does not do anything) ? */
char implicit; char implicit;
} __attribute__((aligned(32))); } SWIFT_STRUCT_ALIGN;
/* Function prototypes. */ /* Function prototypes. */
void task_unlock(struct task *t); void task_unlock(struct task *t);
......
...@@ -319,6 +319,9 @@ void units_get_base_unit_exponants_array(float baseUnitsExp[5], ...@@ -319,6 +319,9 @@ void units_get_base_unit_exponants_array(float baseUnitsExp[5],
break; break;
case UNIT_CONV_VOLUME: case UNIT_CONV_VOLUME:
baseUnitsExp[UNIT_LENGTH] = 3.f;
case UNIT_CONV_INV_VOLUME:
baseUnitsExp[UNIT_LENGTH] = -3.f; baseUnitsExp[UNIT_LENGTH] = -3.f;
} }
} }
......
...@@ -90,7 +90,8 @@ enum UnitConversionFactor { ...@@ -90,7 +90,8 @@ enum UnitConversionFactor {
UNIT_CONV_MAGNETIC_FIELD, UNIT_CONV_MAGNETIC_FIELD,
UNIT_CONV_MAGNETIC_INDUCTANCE, UNIT_CONV_MAGNETIC_INDUCTANCE,
UNIT_CONV_TEMPERATURE, UNIT_CONV_TEMPERATURE,
UNIT_CONV_VOLUME UNIT_CONV_VOLUME,
UNIT_CONV_INV_VOLUME
}; };
void units_init_cgs(struct UnitSystem*); void units_init_cgs(struct UnitSystem*);
......
...@@ -102,10 +102,6 @@ int main() { ...@@ -102,10 +102,6 @@ int main() {
int i, j, k, offset[3]; int i, j, k, offset[3];
struct part *p; struct part *p;
struct hydro_props hp;
hp.target_neighbours = 48.;
hp.delta_neighbours = 1.;
hp.max_smoothing_iterations = 30;
int N = 10; int N = 10;
float dim = 1.; float dim = 1.;
...@@ -146,11 +142,24 @@ int main() { ...@@ -146,11 +142,24 @@ int main() {
/* Create the infrastructure */ /* Create the infrastructure */
struct space space; struct space space;
space.periodic = 0; space.periodic = 0;
space.h_max = 1.; space.cell_min = 1.;
struct phys_const prog_const;
prog_const.const_newton_G = 1.f;
struct hydro_props hp;
hp.target_neighbours = 48.f;
hp.delta_neighbours = 2.;
hp.max_smoothing_iterations = 1;
hp.CFL_condition = 0.1;
struct engine e; struct engine e;
e.s = &space; bzero(&e, sizeof(struct engine));
e.hydro_properties = &hp; e.hydro_properties = &hp;
e.physical_constants = &prog_const;
e.s = &space;
e.time = 0.1f;
e.ti_current = 1;
struct runner r; struct runner r;
r.e = &e; r.e = &e;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment