Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
253c9703
Commit
253c9703
authored
Jul 09, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ModSim ass4 taddeus: Added 1 x-step for better drawing results.
parent
bdc22082
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
16 deletions
+17
-16
modsim/ass4_taddeus/vibstring/par.c
modsim/ass4_taddeus/vibstring/par.c
+3
-3
modsim/ass4_taddeus/vibstring/par.sh
modsim/ass4_taddeus/vibstring/par.sh
+4
-0
modsim/ass4_taddeus/vibstring/report/report.tex
modsim/ass4_taddeus/vibstring/report/report.tex
+1
-1
modsim/ass4_taddeus/vibstring/seq.c
modsim/ass4_taddeus/vibstring/seq.c
+9
-12
No files found.
modsim/ass4_taddeus/vibstring/par.c
View file @
253c9703
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
#include <mpi.h>
#include <mpi.h>
#include <assert.h>
#include <assert.h>
#define VERBOSE
double
**
y
=
NULL
;
double
**
y
=
NULL
;
int
tasks
,
rank
,
steps
,
start
;
int
tasks
,
rank
,
steps
,
start
;
FILE
*
file
;
FILE
*
file
;
...
@@ -64,8 +66,6 @@ void init_plucked(double l, double dx, double xp) {
...
@@ -64,8 +66,6 @@ void init_plucked(double l, double dx, double xp) {
init_borders
();
init_borders
();
}
}
#define VERBOSE
#ifdef VERBOSE
#ifdef VERBOSE
#define PRINT_FORMAT "%e"
#define PRINT_FORMAT "%e"
...
@@ -177,7 +177,7 @@ int main(int argc, char **argv) {
...
@@ -177,7 +177,7 @@ int main(int argc, char **argv) {
file
=
fopen
(
filename
,
"w"
);
file
=
fopen
(
filename
,
"w"
);
// Calculate the indices of the string to calculate
// Calculate the indices of the string to calculate
total_steps
=
(
int
)
ceil
(
l
/
dx
);
total_steps
=
(
int
)
ceil
(
l
/
dx
)
+
1
;
steps
=
total_steps
/
tasks
;
steps
=
total_steps
/
tasks
;
start
=
steps
*
rank
;
start
=
steps
*
rank
;
...
...
modsim/ass4_taddeus/vibstring/par.sh
View file @
253c9703
#!/bin/bash
#!/bin/bash
if
[
$#
-lt
7
]
;
then
echo
"Usage:
$0
NUM_PROCESSES INIT_METHOD TIME_STEPS LENGTH DX TAU N|XP"
exit
1
fi
mpirun
-np
${
1
-4
}
./par
${
@
:2:
$#}
mpirun
-np
${
1
-4
}
./par
${
@
:2:
$#}
#mpirun -np
${
1
-4
}
./par sinus 100 1 .01 1 1
#mpirun -np
${
1
-4
}
./par sinus 100 1 .01 1 1
#mpirun -np
${
1
-4
}
--mca pls_rsh_agent rsa \
#mpirun -np
${
1
-4
}
--mca pls_rsh_agent rsa \
...
...
modsim/ass4_taddeus/vibstring/report/report.tex
View file @
253c9703
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
\section
{
Inleiding
}
\section
{
Inleiding
}
Het tweede deel van practicumopdracht 4 omhelst het programmeren van een
\section
{
Theorie
}
\section
{
Theorie
}
...
...
modsim/ass4_taddeus/vibstring/seq.c
View file @
253c9703
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
#include <string.h>
#include <string.h>
#include <math.h>
#include <math.h>
#define VERBOSE
double
**
y
=
NULL
,
dx
;
double
**
y
=
NULL
,
dx
;
int
steps
,
time
;
int
steps
,
time
;
...
@@ -34,8 +36,6 @@ void init_plucked(double l, double xp) {
...
@@ -34,8 +36,6 @@ void init_plucked(double l, double xp) {
y
[
2
][
steps
-
1
]
=
y
[
1
][
steps
-
1
]
=
y
[
0
][
steps
-
1
];
y
[
2
][
steps
-
1
]
=
y
[
1
][
steps
-
1
]
=
y
[
0
][
steps
-
1
];
}
}
#define VERBOSE
#ifdef VERBOSE
#ifdef VERBOSE
#define PRINT_FORMAT "%e"
#define PRINT_FORMAT "%e"
...
@@ -62,8 +62,8 @@ void calculate_steps(int time, double tau) {
...
@@ -62,8 +62,8 @@ void calculate_steps(int time, double tau) {
// position at t = 0 and the information that y(x, -dt) == y(x, dt)
// position at t = 0 and the information that y(x, -dt) == y(x, dt)
for
(
i
=
1
;
i
<
steps
-
1
;
i
++
)
{
for
(
i
=
1
;
i
<
steps
-
1
;
i
++
)
{
x
=
i
*
dx
;
x
=
i
*
dx
;
y
[
1
][
i
]
=
y
[
0
][
i
]
+
.
5
*
tau
*
tau
*
(
y
[
0
][
i
-
1
]
-
2
*
y
[
0
][
i
]
y
[
1
][
i
]
=
y
[
0
][
i
]
+
.
5
*
tau
*
tau
*
(
y
[
0
][
i
-
1
]
-
2
*
y
[
0
][
i
]
+
y
[
0
][
i
+
1
]);
+
y
[
0
][
i
+
1
]);
}
}
#ifdef VERBOSE
#ifdef VERBOSE
...
@@ -86,7 +86,7 @@ void calculate_steps(int time, double tau) {
...
@@ -86,7 +86,7 @@ void calculate_steps(int time, double tau) {
for
(
t
=
2
;
t
<
time
;
t
++
)
{
for
(
t
=
2
;
t
<
time
;
t
++
)
{
for
(
i
=
1
;
i
<
steps
-
1
;
i
++
)
{
for
(
i
=
1
;
i
<
steps
-
1
;
i
++
)
{
y
[
next
][
i
]
=
2
*
y
[
current
][
i
]
-
y
[
prev
][
i
]
+
tau
*
tau
y
[
next
][
i
]
=
2
*
y
[
current
][
i
]
-
y
[
prev
][
i
]
+
tau
*
tau
*
(
y
[
current
][
i
-
1
]
-
2
*
y
[
current
][
i
]
+
y
[
current
][
i
+
1
]);
*
(
y
[
current
][
i
-
1
]
-
2
*
y
[
current
][
i
]
+
y
[
current
][
i
+
1
]);
}
}
#ifdef VERBOSE
#ifdef VERBOSE
...
@@ -126,14 +126,11 @@ int main(int argc, const char **argv) {
...
@@ -126,14 +126,11 @@ int main(int argc, const char **argv) {
tau
=
atof
(
argv
[
5
]);
tau
=
atof
(
argv
[
5
]);
constant
=
atof
(
argv
[
6
]);
constant
=
atof
(
argv
[
6
]);
// Allocate a 3xN two-dimensional area that
functions as a cyclic buffe
r
// Allocate a 3xN two-dimensional area that
acts as a cyclic buffer fo
r
//
for
three states of the string (previous, current, next)
// three states of the string (previous, current, next)
steps
=
(
int
)
ceil
(
l
/
dx
);
steps
=
(
int
)
ceil
(
l
/
dx
)
+
1
;
if
(
(
y
=
(
double
**
)
malloc
(
3
*
sizeof
(
double
*
)))
==
NULL
)
{
y
=
(
double
**
)
malloc
(
3
*
sizeof
(
double
*
));
puts
(
"Error: could not allocate memory."
);
exit
(
EXIT_FAILURE
);
}
for
(
i
=
0
;
i
<
3
;
i
++
)
for
(
i
=
0
;
i
<
3
;
i
++
)
y
[
i
]
=
(
double
*
)
malloc
(
steps
*
sizeof
(
double
));
y
[
i
]
=
(
double
*
)
malloc
(
steps
*
sizeof
(
double
));
...
...
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