Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LAMBERT Jean-charles
unsio
Commits
136741da
Commit
136741da
authored
Jun 03, 2016
by
LAMBERT Jean-charles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check if gravity files exists
parent
13c2738d
Pipeline
#213
skipped
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
24 deletions
+44
-24
src/camr.cc
src/camr.cc
+23
-10
src/camr.h
src/camr.h
+4
-3
src/snapshotramses.cc
src/snapshotramses.cc
+17
-11
No files found.
src/camr.cc
View file @
136741da
...
...
@@ -33,7 +33,7 @@ CAmr::CAmr(const std::string _indir, const bool _v)
verbose
=
_v
;
indir
=
_indir
;
infile
=
""
;
// keep filename untill last /
int
found
=
indir
.
find_last_of
(
"/"
);
if
(
found
!=
(
int
)
std
::
string
::
npos
&&
(
int
)
indir
.
rfind
(
"output_"
)
<
found
)
{
...
...
@@ -51,9 +51,21 @@ CAmr::CAmr(const std::string _indir, const bool _v)
}
infile
=
indir
+
"/amr_"
+
s_run_index
+
".out00001"
;
testhydrofile
=
indir
+
"/hydro_"
+
s_run_index
+
".out00001"
;
// check gravity file is present
std
::
string
gravityfile
=
indir
+
"/grav_"
+
s_run_index
+
".out00001"
;
if
(
grav
.
open
(
gravityfile
))
{
is_gravity
=
true
;
grav
.
close
();
}
else
{
is_gravity
=
false
;
std
::
cerr
<<
"GRAVITY files are missing....
\n
"
;
}
if
(
verbose
)
std
::
cerr
<<
"Run index = "
<<
s_run_index
<<
" infile=["
<<
infile
<<
"]
\n
"
;
}
// readHeader
if
(
amr
.
open
(
infile
))
{
readHeader
();
...
...
@@ -120,12 +132,10 @@ int CAmr::readHeader()
amr
.
readDataBlock
((
char
*
)
&
ngrid_current
);
amr
.
readDataBlock
((
char
*
)
&
header
.
boxlen
);
std
::
cerr
<<
"BOX LEN ="
<<
header
.
boxlen
<<
"
\n
"
;
amr
.
skipBlock
(
3
);
// noutput,iout,ifout
// tout
// aout
amr
.
readDataBlock
((
char
*
)
&
header
.
time
);
std
::
cerr
<<
"TIME ="
<<
header
.
time
<<
"
\n
"
;
amr
.
skipBlock
(
4
);
// dtold
// dtnew
// nstep,nstep_coarse
...
...
@@ -222,7 +232,8 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
// --------------
// Open GRAV file and skip header
if
(
req_bits
&
POT_BIT
||
req_bits
&
ACC_BIT
)
{
nvarg
=
0
;
if
(
is_gravity
&&
(
req_bits
&
POT_BIT
||
req_bits
&
ACC_BIT
))
{
std
::
string
gravfile
=
indir
+
"/grav_"
+
s_run_index
+
".out"
+
osf
.
str
();
//if (verbose) std::cerr << "CAmr::loadData hydrofile-> ["<<hydrofile << "]\n";
grav
.
open
(
gravfile
,
count_only
);
...
...
@@ -232,7 +243,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
// ndim = 3; nvarg =4, phi,ax,ay,az
// ndim = 2; nvarg =3, phi,ax,ay
if
(
verbose
)
{
std
::
cerr
<<
"
\n
WARNING
\n
We assume that you are using ramses data files produces with new RAMSES released
\n
"
;
//
std::cerr << "\nWARNING\nWe assume that you are using ramses data files produces with new RAMSES released\n";
}
grav
.
skipBlock
(
2
);
// levelmax,nboundary
}
...
...
@@ -260,7 +271,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
son
=
new
int
[
ngrida
*
twotondim
];
if
(
!
count_only
)
{
var
=
new
double
[
ngrida
*
twotondim
*
nvarh
];
if
(
req_bits
&
POT_BIT
||
req_bits
&
ACC_BIT
)
{
if
(
is_gravity
&&
(
req_bits
&
POT_BIT
||
req_bits
&
ACC_BIT
)
)
{
varg
=
new
double
[
ngrida
*
twotondim
*
nvarg
];
}
}
...
...
@@ -312,7 +323,7 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
//
// Read GRAV data
//
if
(
req_bits
&
POT_BIT
||
req_bits
&
ACC_BIT
)
{
if
(
is_gravity
&&
(
req_bits
&
POT_BIT
||
req_bits
&
ACC_BIT
)
)
{
grav
.
skipBlock
(
2
);
if
(
!
count_only
&&
ngridfile
[
ilevel
][
j
]
>
0
)
{
// Read grav variables
...
...
@@ -390,11 +401,11 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
//
// Get gavitationnal data
//
if
(
req_bits
&
POT_BIT
&&
(
nvarg
==
ndim
+
1
))
{
if
(
is_gravity
&&
(
req_bits
&
POT_BIT
&&
(
nvarg
==
ndim
+
1
))
)
{
particles
->
phi
.
push_back
(
varg
[
0
*
ngrida
*
twotondim
+
ind
*
ngrida
+
i
]);
particles
->
load_bits
|=
POT_BIT
;
}
if
(
req_bits
&
ACC_BIT
&&
nvarg
>=
ndim
)
{
if
(
is_gravity
&&
(
req_bits
&
ACC_BIT
&&
nvarg
>=
ndim
)
)
{
int
offset
=
0
;
if
(
nvarg
==
ndim
+
1
)
{
// there is pot/ax/ay/az
offset
=
1
;
// shift to ax
...
...
@@ -465,7 +476,9 @@ template <class T> int CAmr::loadData(uns::CParticles<T> * particles,
}
// ilevel
amr
.
close
();
hydro
.
close
();
grav
.
close
();
if
(
is_gravity
)
{
grav
.
close
();
}
}
//for (int icpu=0 ....
return
nbody
;
}
...
...
src/camr.h
View file @
136741da
...
...
@@ -56,8 +56,9 @@ public:
}
lmin
=
std
::
min
((
int
)
x
[
6
],
lmax
-
1
);
std
::
cerr
<<
"min = "
<<
(
int
)
x
[
6
]
<<
" lmax="
<<
lmax
<<
" lmin="
<<
lmin
<<
"
\n
"
;
//exit(1);
if
(
verbose
)
{
std
::
cerr
<<
"min = "
<<
(
int
)
x
[
6
]
<<
" lmax="
<<
lmax
<<
" lmin="
<<
lmin
<<
"
\n
"
;
}
}
bool
isValid
();
template
<
class
T
>
int
loadData
(
uns
::
CParticles
<
T
>
*
particles
,
...
...
@@ -69,7 +70,7 @@ public:
private:
// some variables
bool
verbose
,
valid
;
bool
verbose
,
valid
,
is_gravity
;
std
::
string
infile
,
testhydrofile
,
indir
;
int
select
,
nselect
;
int
nbody
;
...
...
src/snapshotramses.cc
View file @
136741da
...
...
@@ -108,19 +108,22 @@ template <class T> int CSnapshotRamsesIn<T>::nextFrame(uns::UserSelection &user_
part
->
loadData
(
particles
,
this
->
req_bits
,
comp_bits
);
}
if
(
comp_bits
&
GAS_BIT
&&
amr
->
isValid
())
{
std
::
cerr
<<
"in gas
\n
"
;
amr
->
setBoundary
(
x
);
amr
->
loadData
(
particles
,
this
->
req_bits
);
}
std
::
cerr
<<
"ntot = "
<<
particles
->
ntot
<<
"
\n
"
;
std
::
cerr
<<
"ngas = "
<<
particles
->
ngas
<<
"
\n
"
;
std
::
cerr
<<
"ndm = "
<<
particles
->
ndm
<<
"
\n
"
;
std
::
cerr
<<
"nstars = "
<<
particles
->
nstars
<<
"
\n
"
;
std
::
cerr
<<
"Box len="
<<
amr
->
getHeader
()
->
boxlen
<<
"
\n
"
;
if
(
this
->
verbose
)
{
std
::
cerr
<<
"ntot = "
<<
particles
->
ntot
<<
"
\n
"
;
std
::
cerr
<<
"ngas = "
<<
particles
->
ngas
<<
"
\n
"
;
std
::
cerr
<<
"ndm = "
<<
particles
->
ndm
<<
"
\n
"
;
std
::
cerr
<<
"nstars = "
<<
particles
->
nstars
<<
"
\n
"
;
std
::
cerr
<<
"Box len="
<<
amr
->
getHeader
()
->
boxlen
<<
"
\n
"
;
}
//if (this->req_bits) {
std
::
cerr
<<
"Start reordering...
\n
"
;
//std::cerr << "Start reordering...\n";
if
(
particles
->
indexes
.
size
()
>
0
)
{
reorderParticles
(
user_select
);
std
::
cerr
<<
"Stop reordering...
\n
"
;
}
//std::cerr << "Stop reordering...\n";
//}
status
=
1
;
}
...
...
@@ -140,7 +143,8 @@ template <class T> int CSnapshotRamsesIn<T>::close()
// according to user request
template
<
class
T
>
int
CSnapshotRamsesIn
<
T
>::
reorderParticles
(
uns
::
UserSelection
&
user_select
)
{
std
::
cerr
<<
"Nbody particles loaded="
<<
particles
->
ntot
<<
"
\n
"
;
if
(
this
->
verbose
)
std
::
cerr
<<
"Nbody particles loaded="
<<
particles
->
ntot
<<
"
\n
"
;
std
::
vector
<
int
>
offset_comp
(
6
,
-
1
);
// init 6 offsets with value =-1
std
::
vector
<
int
>
npart_comp
(
6
,
0
);
// initialise #part per component to ZERO
char
*
comp
[]
=
{
(
char
*
)
"gas"
,(
char
*
)
"halo"
,(
char
*
)
"disk"
,(
char
*
)
"bulge"
,(
char
*
)
"stars"
,(
char
*
)
"bndry"
,(
char
*
)
"all"
};
...
...
@@ -207,8 +211,10 @@ template <class T> int CSnapshotRamsesIn<T>::reorderParticles(uns::UserSelection
// insert "all" at the beginning of componentRangeVector
this
->
crv
.
insert
(
it
,
cr
);
for
(
unsigned
int
i
=
0
;
i
<
offset_comp
.
size
();
i
++
)
{
std
::
cerr
<<
"i="
<<
i
<<
"["
<<
comp
[
i
]
<<
"] offset="
<<
offset_comp
[
i
]
<<
"
\n
"
;
if
(
this
->
verbose
)
{
for
(
unsigned
int
i
=
0
;
i
<
offset_comp
.
size
();
i
++
)
{
std
::
cerr
<<
"i="
<<
i
<<
"["
<<
comp
[
i
]
<<
"] offset="
<<
offset_comp
[
i
]
<<
"
\n
"
;
}
}
if
(
this
->
verbose
)
uns
::
ComponentRange
::
list
(
&
this
->
crv
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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