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
e2afccea
Commit
e2afccea
authored
12 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
guess initial time step if dt_min is zero.
Former-commit-id: 67c1f9a70e35d07310a59e4c00b2ae08eef12952
parent
b551eafe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/engine.c
+15
-4
15 additions, 4 deletions
src/engine.c
src/engine.h
+4
-1
4 additions, 1 deletion
src/engine.h
with
19 additions
and
5 deletions
src/engine.c
+
15
−
4
View file @
e2afccea
...
@@ -519,6 +519,8 @@ void engine_step ( struct engine *e , int sort_queues ) {
...
@@ -519,6 +519,8 @@ void engine_step ( struct engine *e , int sort_queues ) {
e
->
step
+=
1
;
e
->
step
+=
1
;
/* Does the time step need adjusting? */
/* Does the time step need adjusting? */
if
(
e
->
dt
==
0
)
e
->
dt
=
e
->
dt_orig
;
while
(
dt_min
<
e
->
dt
)
{
while
(
dt_min
<
e
->
dt
)
{
e
->
dt
*=
0
.
5
;
e
->
dt
*=
0
.
5
;
e
->
step
*=
2
;
e
->
step
*=
2
;
...
@@ -529,6 +531,9 @@ void engine_step ( struct engine *e , int sort_queues ) {
...
@@ -529,6 +531,9 @@ void engine_step ( struct engine *e , int sort_queues ) {
e
->
step
/=
2
;
e
->
step
/=
2
;
printf
(
"engine_step: dt_min is larger than twice the time step, adjusting to dt=%e.
\n
"
,
e
->
dt
);
printf
(
"engine_step: dt_min is larger than twice the time step, adjusting to dt=%e.
\n
"
,
e
->
dt
);
}
}
/* Set the system time. */
e
->
time
=
e
->
dt
*
e
->
step
;
TIMER_TOC2
(
timer_step
);
TIMER_TOC2
(
timer_step
);
...
@@ -553,6 +558,7 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
...
@@ -553,6 +558,7 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
cpu_set_t
cpuset
;
cpu_set_t
cpuset
;
#endif
#endif
int
k
;
int
k
;
float
dt_min
=
dt
;
/* Store the values. */
/* Store the values. */
e
->
s
=
s
;
e
->
s
=
s
;
...
@@ -571,11 +577,16 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
...
@@ -571,11 +577,16 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
e
->
barrier_count
=
0
;
e
->
barrier_count
=
0
;
/* Run through the parts and get the minimum time step. */
/* Run through the parts and get the minimum time step. */
e
->
dt_orig
=
dt
;
for
(
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
for
(
k
=
0
;
k
<
s
->
nr_parts
;
k
++
)
if
(
s
->
parts
[
k
].
dt
>
0
.
0
f
)
if
(
s
->
parts
[
k
].
dt
<
dt_min
)
while
(
s
->
parts
[
k
].
dt
<
dt
)
dt_min
=
s
->
parts
[
k
].
dt
;
dt
*=
0
.
5
;
if
(
dt_min
==
0
.
0
f
)
e
->
dt_min
=
dt
;
dt
=
0
.
0
f
;
else
while
(
dt
>
dt_min
)
dt
*=
0
.
5
f
;
e
->
dt
=
dt
;
/* Allocate the queues. */
/* Allocate the queues. */
if
(
posix_memalign
(
(
void
*
)(
&
e
->
queues
)
,
64
,
nr_queues
*
sizeof
(
struct
queue
)
)
!=
0
)
if
(
posix_memalign
(
(
void
*
)(
&
e
->
queues
)
,
64
,
nr_queues
*
sizeof
(
struct
queue
)
)
!=
0
)
...
...
This diff is collapsed.
Click to expand it.
src/engine.h
+
4
−
1
View file @
e2afccea
...
@@ -57,11 +57,14 @@ struct engine {
...
@@ -57,11 +57,14 @@ struct engine {
float
dt_min
;
float
dt_min
;
/* The system time step. */
/* The system time step. */
float
dt
;
float
dt
,
dt_orig
;
/* The current step number. */
/* The current step number. */
int
step
;
int
step
;
/* The current system time. */
float
time
;
/* Data for the threads' barrier. */
/* Data for the threads' barrier. */
pthread_mutex_t
barrier_mutex
;
pthread_mutex_t
barrier_mutex
;
pthread_cond_t
barrier_cond
;
pthread_cond_t
barrier_cond
;
...
...
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