Introduction
Introduction Statistics Contact Development Disclaimer Help
tput tests in separate folder - slidergrid - grid of elastic sliders on a frict…
git clone git://src.adamsgaard.dk/slidergrid
Log
Files
Refs
README
LICENSE
---
commit faa21e62b93f6998ea8a3108b8b58629a8ed8d5d
parent c3e0b8d528cae8ad2e8b04ff4ea49ca565c50504
Author: Anders Damsgaard <[email protected]>
Date: Wed, 23 Mar 2016 13:01:08 -0700
put tests in separate folder
Diffstat:
M .gitignore | 1 -
M Makefile | 17 ++++-------------
A slidergrid/constants.h | 6 ++++++
M slidergrid/main.c | 3 +--
M slidergrid/simulation.c | 3 +++
D test.c | 46 -----------------------------…
A tests/Makefile | 34 +++++++++++++++++++++++++++++…
A tests/twograins.c | 46 +++++++++++++++++++++++++++++…
8 files changed, 94 insertions(+), 62 deletions(-)
---
diff --git a/.gitignore b/.gitignore
t@@ -1,4 +1,3 @@
-slidergrid
.*.swp
*.o
tags
diff --git a/Makefile b/Makefile
t@@ -2,28 +2,19 @@ CC=gcc
#CFLAGS=-Wall -O3 -march=native
CFLAGS=-Wall -g -pg
LDLIBS=-lm
-SRCFOLDER=slidergrid
+SRCFOLDER=../slidergrid
ESSENTIALOBJS=$(SRCFOLDER)/main.o \
$(SRCFOLDER)/slider.o \
$(SRCFOLDER)/grid.o \
$(SRCFOLDER)/vector_math.o \
$(SRCFOLDER)/simulation.o
-BIN=test
+BIN=example
-default: run-test
+default: example
-run-test: test
- ./$< --verbose
- @#python postprocessing.py --plot-sliders $<-output
- @#rsync -rav test-output /var/www/html/
-
-test: test.o $(ESSENTIALOBJS)
+example: example.o $(ESSENTIALOBJS)
$(CC) $(LDLIBS) $^ -o $@
-profile: $(BIN)
- @gprof $< > $<-profile.txt
- @less $<-profile.txt
-
debug: $(BIN)
@gdb $<
diff --git a/slidergrid/constants.h b/slidergrid/constants.h
t@@ -0,0 +1,6 @@
+#ifndef CONSTANTS_H_
+#define CONSTANTS_H_
+
+const char* VERSION = "beta-0.1";
+
+#endif
diff --git a/slidergrid/main.c b/slidergrid/main.c
t@@ -8,8 +8,7 @@
#include "grid.h"
#include "simulation.h"
#include "debug.h"
-
-const char* VERSION = "beta-0.1";
+#include "constants.h"
void print_usage(char* argv0)
{
diff --git a/slidergrid/simulation.c b/slidergrid/simulation.c
t@@ -2,6 +2,7 @@
#include <math.h>
#include "slider.h"
#include "simulation.h"
+#include "constants.h"
simulation create_simulation()
{
t@@ -129,6 +130,8 @@ int save_general_state_to_file(const simulation* sim, cons…
return 1;
}
+ fprintf(f, "version = %s\n", VERSION);
+ fprintf(f, "id = %s\n", sim->id);
fprintf(f, "id = %s\n", sim->id);
fprintf(f, "N = %d\n", sim->N);
fprintf(f, "time = %f\n", sim->time);
diff --git a/test.c b/test.c
t@@ -1,46 +0,0 @@
-#include "slidergrid/simulation.h"
-#include "slidergrid/grid.h"
-#include "slidergrid/slider.h"
-
-#include <stdio.h>
-
-// test a regular, 2d, orthogonal grid of sliders
-simulation setup_simulation()
-{
- // create empty simulation structure with default values
- simulation sim = create_simulation();
- sim.id = "test";
-
- // initialize grid of sliders
- //int nx = 10;
- int nx = 2;
- int ny = 1;
- int nz = 1;
- sim.N = nx*ny*nz;
- sim.sliders = create_regular_slider_grid(nx, ny, nz, 1.0, 1.0, 1.0);
-
- sim.bond_length_limit = 1.5;
-
- // set slider masses and moments of inertia
- int i;
- for (i=0; i<sim.N; i++) {
-
- // set default values
- initialize_slider_values(&sim.sliders[i]);
-
- // set custom values for certain parameters
- sim.sliders[i].mass = 1.0;
- sim.sliders[i].moment_of_inertia = 1.0e3;
- sim.sliders[i].bond_parallel_stiffness = 1.0e5;
- //sim.sliders[i].bond_parallel_viscosity = 1.0e2;
- }
-
- sim.sliders[0].vel.x = 0.01;
-
- // set temporal parameters
- sim.time = 0.0;
- sim.time_end = 10.0;
- sim.file_interval = 0.1;
-
- return sim;
-}
diff --git a/tests/Makefile b/tests/Makefile
t@@ -0,0 +1,34 @@
+CC=gcc
+#CFLAGS=-Wall -O3 -march=native
+CFLAGS=-Wall -g -pg
+LDLIBS=-lm
+SRCFOLDER=../slidergrid
+ESSENTIALOBJS=$(SRCFOLDER)/main.o \
+ $(SRCFOLDER)/slider.o \
+ $(SRCFOLDER)/grid.o \
+ $(SRCFOLDER)/vector_math.o \
+ $(SRCFOLDER)/simulation.o
+BIN=test
+
+default: run-test
+
+run-test: twograins
+ ./$< --verbose
+ @#python postprocessing.py --plot-sliders $<-output
+ @#rsync -rav test-output /var/www/html/
+
+twograins: twograins.o $(ESSENTIALOBJS)
+ $(CC) $(LDLIBS) $^ -o $@
+
+profile: $(BIN)
+ @gprof $< > $<-profile.txt
+ @less $<-profile.txt
+
+debug: $(BIN)
+ @gdb $<
+
+clean:
+ @$(RM) $(BIN)
+ @$(RM) -r $(BIN)-output
+ @$(RM) *.o
+ @$(RM) $(SRCFOLDER)/*.o
diff --git a/tests/twograins.c b/tests/twograins.c
t@@ -0,0 +1,46 @@
+#include "../slidergrid/simulation.h"
+#include "../slidergrid/grid.h"
+#include "../slidergrid/slider.h"
+
+#include <stdio.h>
+
+// test a regular, 2d, orthogonal grid of sliders
+simulation setup_simulation()
+{
+ // create empty simulation structure with default values
+ simulation sim = create_simulation();
+ sim.id = "test";
+
+ // initialize grid of sliders
+ //int nx = 10;
+ int nx = 2;
+ int ny = 1;
+ int nz = 1;
+ sim.N = nx*ny*nz;
+ sim.sliders = create_regular_slider_grid(nx, ny, nz, 1.0, 1.0, 1.0);
+
+ sim.bond_length_limit = 1.5;
+
+ // set slider masses and moments of inertia
+ int i;
+ for (i=0; i<sim.N; i++) {
+
+ // set default values
+ initialize_slider_values(&sim.sliders[i]);
+
+ // set custom values for certain parameters
+ sim.sliders[i].mass = 1.0;
+ sim.sliders[i].moment_of_inertia = 1.0e3;
+ sim.sliders[i].bond_parallel_stiffness = 1.0e5;
+ //sim.sliders[i].bond_parallel_viscosity = 1.0e2;
+ }
+
+ sim.sliders[0].vel.x = 0.01;
+
+ // set temporal parameters
+ sim.time = 0.0;
+ sim.time_end = 10.0;
+ sim.file_interval = 0.1;
+
+ return sim;
+}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.