Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
bd862b82
Commit
bd862b82
authored
Mar 31, 2016
by
Matthieu Schaller
Browse files
Moved the initialisation of the physical constants to its own file for consistency with the rest.
parent
3354e466
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/Makefile.am
View file @
bd862b82
...
...
@@ -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
\
...
...
src/physical_constants.c
0 → 100644
View file @
bd862b82
/*******************************************************************************
* 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
);
}
src/physical_constants.h
View file @
bd862b82
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 201
2 Pedro Gonnet (ptcedro.gonnet
@durham.ac.uk)
* Copyright (c) 201
6 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 */
src/physical_constants_cgs.h
View file @
bd862b82
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 201
2 Pedro Gonnet (ptcedro.gonnet
@durham.ac.uk)
* Copyright (c) 201
6 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 */
src/swift.h
View file @
bd862b82
...
...
@@ -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"
...
...
src/units.c
View file @
bd862b82
...
...
@@ -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
);
}
src/units.h
View file @
bd862b82
...
...
@@ -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 */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment