Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
46eba013
Commit
46eba013
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Add a constructor for the unit system that gets the 5 base units as direct input.
parent
e3a01e02
No related branches found
No related tags found
1 merge request
!539
Add a constructor for the unit system that gets the 5 base units as direct input.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/main.c
+1
-1
1 addition, 1 deletion
examples/main.c
src/units.c
+22
-2
22 additions, 2 deletions
src/units.c
src/units.h
+3
-3
3 additions, 3 deletions
src/units.h
with
26 additions
and
6 deletions
examples/main.c
+
1
−
1
View file @
46eba013
...
...
@@ -590,7 +590,7 @@ int main(int argc, char *argv[]) {
/* Not restarting so look for the ICs. */
/* Initialize unit system and constants */
units_init
(
&
us
,
params
,
"InternalUnitSystem"
);
units_init
_from_params
(
&
us
,
params
,
"InternalUnitSystem"
);
phys_const_init
(
&
us
,
params
,
&
prog_const
);
if
(
myrank
==
0
&&
verbose
>
0
)
{
message
(
"Internal unit system: U_M = %e g."
,
us
.
UnitMass_in_cgs
);
...
...
This diff is collapsed.
Click to expand it.
src/units.c
+
22
−
2
View file @
46eba013
...
...
@@ -55,6 +55,25 @@ void units_init_cgs(struct unit_system* us) {
us
->
UnitTemperature_in_cgs
=
1
.;
}
/**
* @brief Initialise the unit_system with values for the base units.
*
* @param us The #unit_system to initialise.
* @param U_M_in_cgs The mass unit in [g].
* @param U_L_in_cgs The length unit in [cm].
* @param U_t_in_cgs The time unit in [s].
* @param U_C_in_cgs The current unit in [A].
* @param U_T_in_cgs The temperature unit in [K].
*/
void
units_init
(
struct
unit_system
*
us
,
double
U_M_in_cgs
,
double
U_L_in_cgs
,
double
U_t_in_cgs
,
double
U_C_in_cgs
,
double
U_T_in_cgs
)
{
us
->
UnitMass_in_cgs
=
U_M_in_cgs
;
us
->
UnitLength_in_cgs
=
U_L_in_cgs
;
us
->
UnitTime_in_cgs
=
U_t_in_cgs
;
us
->
UnitCurrent_in_cgs
=
U_C_in_cgs
;
us
->
UnitTemperature_in_cgs
=
U_T_in_cgs
;
}
/**
* @brief Initialises the unit_system structure with the constants given in
* the parameter file.
...
...
@@ -63,8 +82,9 @@ void units_init_cgs(struct unit_system* us) {
* @param params The parsed parameter file.
* @param category The section of the parameter file to read from.
*/
void
units_init
(
struct
unit_system
*
us
,
const
struct
swift_params
*
params
,
const
char
*
category
)
{
void
units_init_from_params
(
struct
unit_system
*
us
,
const
struct
swift_params
*
params
,
const
char
*
category
)
{
char
buffer
[
200
];
sprintf
(
buffer
,
"%s:UnitMass_in_cgs"
,
category
);
...
...
This diff is collapsed.
Click to expand it.
src/units.h
+
3
−
3
View file @
46eba013
...
...
@@ -28,7 +28,7 @@
/**
* @brief The unit system used internally.
*
* This structure contains the conversion factors to the
7
cgs base units to the
* This structure contains the conversion factors to the
5
cgs base units to the
* internal units. It is used everytime a conversion is performed or an i/o
* function is called.
**/
...
...
@@ -96,8 +96,8 @@ enum unit_conversion_factor {
};
void
units_init_cgs
(
struct
unit_system
*
);
void
units_init
(
struct
unit_system
*
,
const
struct
swift_params
*
,
const
char
*
category
);
void
units_init
_from_params
(
struct
unit_system
*
,
const
struct
swift_params
*
,
const
char
*
category
);
void
units_init_default
(
struct
unit_system
*
us
,
const
struct
swift_params
*
params
,
const
char
*
category
,
const
struct
unit_system
*
def
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment