Commit bd862b82 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Moved the initialisation of the physical constants to its own file for consistency with the rest.

parent 3354e466
......@@ -35,13 +35,15 @@ endif
# List required headers
include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
common_io.h single_io.h multipole.h map.h tools.h partition.h clocks.h parser.h
common_io.h single_io.h multipole.h map.h tools.h partition.h clocks.h parser.h \
physical_constants.h physical_constants_cgs.h
# Common source files
AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
serial_io.c timers.c debug.c scheduler.c proxy.c parallel_io.c \
units.c common_io.c single_io.c multipole.c version.c map.c \
kernel.c tools.c part.c partition.c clocks.c parser.c gravity/Default/potentials.c
kernel.c tools.c part.c partition.c clocks.c parser.c gravity/Default/potentials.c \
physical_constants.c
# Include files for distribution, not installation.
nobase_noinst_HEADERS = approx_math.h atomic.h cycle.h error.h inline.h kernel.h vector.h \
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Tom Theuns (tom.theuns@durham.ac.uk)
* 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/>.
*
******************************************************************************/
#include "physical_constants_cgs.h"
#include "physical_constants.h"
void initPhysicalConstants(struct UnitSystem* us, struct phys_const* prog_const)
{
float dimension[5] = {1, -3, 2, 0, 0};
prog_const->newton_gravity = NEWTON_GRAVITY_CGS * generalConversionFactor(us, dimension);
}
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2012 Pedro Gonnet (ptcedro.gonnet@durham.ac.uk)
* Copyright (c) 2016 Tom Theuns (tom.theuns@durham.ac.uk)
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
......@@ -20,10 +20,19 @@
#ifndef SWIFT_PHYSICAL_CONSTANTS_H
#define SWIFT_PHYSICAL_CONSTANTS_H
#include "units.h"
/* physical constants in in defined programme units */
struct phys_const{
double newton_gravity;
};
/**
* @brief Converts physical constants to the internal unit system
*/
void initPhysicalConstants(struct UnitSystem* us, struct phys_const* prog_const);
#endif /* SWIFT_PHYSICAL_CONSTANTS_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2012 Pedro Gonnet (ptcedro.gonnet@durham.ac.uk)
* Copyright (c) 2016 Tom Theuns (tom.theuns@durham.ac.uk)
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
* This program is free software: you can redistribute it and/or modify
......@@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_PHYSICAL_CONSTANTS_CGS_H
#define SWIFT_PHYSICAL_CONSTANTS_CGS_H
/* physical constants in cgs */
#define NEWTON_GRAVITY_CGS 6.672e-8f
......@@ -27,3 +29,6 @@
/* Hydrodynamical constants. */
#define const_hydro_gamma (5.0f / 3.0f)
#endif /* SWIFT_PHYSICAL_CONSTANTS_CGS_H */
......@@ -40,6 +40,7 @@
#include "parser.h"
#include "part.h"
#include "partition.h"
#include "physical_constants.h"
#include "queue.h"
#include "runner.h"
#include "scheduler.h"
......
......@@ -39,13 +39,12 @@
/* Includes. */
#include "const.h"
#include "error.h"
#include "physical_constants_cgs.h"
/**
* @brief Initialises the UnitSystem structure with the constants given in
* const.h
* @param us The UnitSystem to initialize
*/
void initUnitSystem(struct UnitSystem* us) {
us->UnitMass_in_cgs = const_unit_mass_in_cgs;
us->UnitLength_in_cgs = const_unit_length_in_cgs;
......@@ -445,8 +444,3 @@ void generalConversionString(char* buffer, struct UnitSystem* us,
strncat(buffer, "]", 2);
}
void initPhysicalConstants(struct UnitSystem* us, struct phys_const* prog_const)
{
float dimension[5] = {1, -3, 2, 0, 0};
prog_const->newton_gravity = NEWTON_GRAVITY_CGS * generalConversionFactor(us, dimension);
}
......@@ -18,7 +18,6 @@
******************************************************************************/
#ifndef SWIFT_UNITS_H
#define SWIFT_UNITS_H
#include "physical_constants.h"
/**
* @brief The unit system used internally.
*
......@@ -157,10 +156,4 @@ void conversionString(char* buffer, struct UnitSystem* us,
enum UnitConversionFactor unit);
/**
* @brief Converts physical constants to the internal unit system
*/
void initPhysicalConstants(struct UnitSystem* us, struct phys_const* prog_const);
#endif /* SWIFT_UNITS_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment