FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
idefix/src/units.cpp at master · idefix-code/idefix · GitHub
idefix-code
idefix
Repository navigation
Code
Issues
3
(3)
Pull requests
9
(9)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
idefix
/
src
/
units.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (54 loc) · 2.02 KB
Breadcrumbs
idefix
/
src
/
units.cpp
Copy path
File metadata and controls
62 lines (54 loc) · 2.02 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
***********************************************************************************
//
Idefix MHD astrophysical code
//
//
Source file src/units.cpp
//
//
Last modified : 04/2025
//
//
Copyright(C) by :
//
- Geoffroy Lesur <geoffroy.lesur@univ-grenoble-alpes.fr> (IPAG/UGA/CNRS - 2025)
//
and other code contributors
//
//
Licensed under CeCILL 2.1 License, see COPYING for more information
//
***********************************************************************************
#
include
"
units.hpp
"
#
include
"
idefix.hpp
"
#
include
"
input.hpp
"
void
idfx::Units::Init
(Input &input) {
if
(input.
CheckBlock
(
"
Units
"
)) {
this
->
_length
= input.
GetOrSet
<real>(
"
Units
"
,
"
length
"
,
0
,
1.0
);
this
->
_velocity
= input.
GetOrSet
<real>(
"
Units
"
,
"
velocity
"
,
0
,
1.0
);
this
->
_density
= input.
GetOrSet
<real>(
"
Units
"
,
"
density
"
,
0
,
1.0
);
this
->
ComputeUnits
();
}
}
void
idfx::Units::SetDensity
(
const
real in) {
this
->
_density
= in;
this
->
ComputeUnits
();
}
void
idfx::Units::SetLength
(
const
real in) {
this
->
_length
= in;
this
->
ComputeUnits
();
}
void
idfx::Units::SetVelocity
(
const
real in) {
this
->
_velocity
= in;
this
->
ComputeUnits
();
}
void
idfx::Units::ShowConfig
() {
if
(_isInitialized) {
idfx::cout <<
"
Units: [Length] =
"
<<
this
->
_length
<<
"
cm
"
<< std::endl;
idfx::cout <<
"
Units: [Velocity] =
"
<<
this
->
_velocity
<<
"
cm/s
"
<< std::endl;
idfx::cout <<
"
Units: [Density] =
"
<<
this
->
_density
<<
"
g/cm3
"
<< std::endl;
idfx::cout <<
"
Units: [Energy] =
"
<<
this
->
_energy
<<
"
erg/cm3
"
<< std::endl;
idfx::cout <<
"
Units: [Time] =
"
<<
this
->
_time
<<
"
s
"
<< std::endl;
idfx::cout <<
"
Units: [Temperature] =
"
<<
this
->
_Kelvin
<<
"
K
"
<< std::endl;
idfx::cout <<
"
Units: [Mag. Field] =
"
<<
this
->
_magField
<<
"
G
"
<< std::endl;
}
}
void
idfx::Units::ComputeUnits
() {
this
->
_isInitialized
=
true
;
this
->
_magField
=
std::sqrt
(
4
*
M_PI
*_density*_velocity*_velocity);
this
->
_Kelvin
= u * _velocity*_velocity/k_B;
this
->
_energy
= _density*_velocity*_velocity;
this
->
_time
= _length/_velocity;
}
Back
|
FazBrowse Home
|
New Git URL