Commit eb5f2dc2 authored by Sergey Litvinov's avatar Sergey Litvinov
Browse files

copy-paste u/rbc; use example.mk

parent 07751fdd
include ../../../conf.mk
LD = $(CXX)
UDX_CXXFLAGS = $(shell u.pkg-config udx_cuda --cflags)
UDX_LDFLAGS = $(shell u.pkg-config udx_cpu --libs) $(shell u.pkg-config udx_cuda --libs)
S = $(shell u.cp.s)
include $S/../conf.mk
include $S/../make/example.mk
main: main.o; $(LD) $^ $(UDX_LDFLAGS) -o $@
main.o: main.cu; $(NCC) $(UDX_CXXFLAGS) $< -c -o $@
main: main.o
install: main; u.install main $(BIN)
main.o: dev.h
clean:; rm -f main main.o
.PHONY: install clean
include ../../../conf.mk
LD = $(CXX)
UDX_CXXFLAGS = `u.pkg-config udx_cpu --cflags`
UDX_LDFLAGS = `u.pkg-config udx_cpu --libs`
S = $(shell u.cp.s)
include $S/../conf.mk
include $S/../make/example.mk
main: main.o; $(LD) $< $(UDX_LDFLAGS) -o $@
main.o: main.cpp; $(CXX) $(CXXFLAGS) $(UDX_CXXFLAGS) $^ -c -o $@
main: main.o
install: main; u.install main $(BIN)
clean:; rm -f main main.o
......
S = $(shell u.cp.s)
include $S/../conf.mk
include $S/../make/example.mk
main: main.o
install: main; u.install main $(BIN)
clean:; rm -f main main.o
.PHONY: install clean
#include <stdio.h>
#include <assert.h>
#include <mpi.h>
#include <conf.h>
#include "inc/conf.h"
#include "inc/def.h"
#include "utils/error.h"
#include "utils/imp.h"
#include "conf/imp.h"
#include "d/api.h"
#include "utils/msg.h"
#include "utils/mc.h"
#include "inc/dev.h"
#include "utils/cc.h"
#include "coords/ini.h"
#include "rbc/type.h"
#include "rbc/imp.h"
#include "rbc/force/area_volume/imp.h"
#include "rbc/force/imp.h"
#include "io/mesh/imp.h"
#include "io/mesh_read/imp.h"
#include "mpi/wrapper.h"
#include "mpi/glb.h"
static void area_volume_hst(AreaVolume *area_volume, int nc, const Particle *pp, /**/ float *hst) {
float *dev;
UC(area_volume_compute(area_volume, nc, pp, /**/ &dev));
cD2H(hst, dev, 2*nc);
}
static void run0(RbcQuants q) {
float area, volume, av[2];
UC(area_volume_hst(q.area_volume, q.nc, q.pp, /**/ av));
area = av[0]; volume = av[1];
printf("%g %g\n", area, volume);
}
static void run1(MPI_Comm cart, const Coords *coords, MeshRead *off, const char *ic, RbcQuants q) {
rbc_gen_mesh(coords, cart, off, ic, /**/ &q);
rbc_gen_freeze(cart, /**/ &q);
UC(run0(q));
}
void run(MPI_Comm cart, const Coords *coords, const char *cell, const char *ic) {
RbcQuants q;
MeshRead *off;
UC(mesh_read_ini_off(cell, /**/ &off));
UC(rbc_ini(MAX_CELL_NUM, false, off, &q));
UC(run1(cart, coords, off, ic, q));
UC(mesh_read_fin(off));
UC(rbc_fin(&q));
}
int main(int argc, char **argv) {
Coords *coords;
Config *cfg;
int dims[3];
MPI_Comm cart;
m::ini(&argc, &argv);
m::get_dims(&argc, &argv, dims);
m::get_cart(MPI_COMM_WORLD, dims, &cart);
UC(conf_ini(&cfg));
UC(conf_read(argc, argv, cfg));
UC(coords_ini_conf(cart, cfg, &coords));
run(cart, coords, "rbc.off", "rbcs-ic.txt");
UC(coords_fin(coords));
UC(conf_fin(cfg));
MC(m::Barrier(cart));
m::fin();
}
S = $(shell u.cp.s)
include $S/../conf.mk
include $S/../make/example.mk
main: main.o
install: main; u.install main $(BIN)
clean:; rm -f main main.o
.PHONY: install clean
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <mpi.h>
#include <conf.h>
#include "inc/conf.h"
#include "inc/def.h"
#include "inc/type.h"
#include "inc/dev.h"
#include "coords/type.h"
#include "coords/ini.h"
#include "utils/imp.h"
#include "utils/msg.h"
#include "utils/error.h"
#include "utils/texo.h"
#include "utils/cc.h"
#include "utils/mc.h"
#include "d/api.h"
#include "rbc/params/imp.h"
#include "rbc/type.h"
#include "rbc/imp.h"
#include "rbc/force/imp.h"
#include "rbc/force/bending/imp.h"
#include "io/mesh_read/imp.h"
#include "mpi/glb.h"
#include "mpi/wrapper.h"
#include "conf/imp.h"
static void write0(Particle p, Force f0) {
enum {X, Y, Z};
float *r, *f;
r = p.r;
f = f0.f;
printf("%g %g %g %g %g %g\n", r[X], r[Y], r[Z], f[X], f[Y], f[Z]);
}
static void write1(int n, Particle *p, Force *f) {
int i;
for (i = 0; i < n; i++) write0(p[i], f[i]);
}
static void write(int n, Particle *p, Force *f) {
Particle *p_hst;
Force *f_hst;
EMALLOC(n, &p_hst);
EMALLOC(n, &f_hst);
cD2H(p_hst, p, n);
cD2H(f_hst, f, n);
write1(n, p_hst, f_hst);
EFREE(p_hst);
EFREE(f_hst);
}
int main(int argc, char **argv) {
Config *cfg;
Coords *coords;
RbcParams *par;
Bending *bending;
const char *cell, *ic;
MPI_Comm cart;
int dims[3];
MeshRead *off;
RbcQuants q;
bool ids = false;
Force *f;
float kb, phi;
m::ini(&argc, &argv);
m::get_dims(&argc, &argv, dims);
m::get_cart(MPI_COMM_WORLD, dims, &cart);
UC(conf_ini(&cfg));
UC(conf_read(argc, argv, cfg));
UC(coords_ini_conf(cart, cfg, &coords));
UC(conf_lookup_string(cfg, "rbc.cell", &cell));
UC(conf_lookup_string(cfg, "rbc.ic", &ic));
UC(conf_lookup_float(cfg, "rbc.kb", &kb));
UC(conf_lookup_float(cfg, "rbc.phi", &phi));
UC(rbc_params_ini(&par));
UC(rbc_params_set_bending(kb, phi, /**/ par));
UC(mesh_read_ini_off(cell, /**/ &off));
UC(rbc_ini(MAX_CELL_NUM, ids, off, &q));
UC(rbc_gen_mesh(coords, cart, off, ic, /**/ &q));
Dalloc(&f, q.n); Dzero(f, q.n);
UC(bending_juelicher_ini(off, &bending));
UC(bending_apply(bending, par, &q, f));
write(q.n, q.pp, f);
Dfree(f);
UC(bending_fin(bending));
rbc_fin(&q);
mesh_read_fin(off);
UC(rbc_params_fin(par));
UC(conf_fin(cfg));
UC(coords_fin(coords));
MC(m::Barrier(cart));
dSync();
m::fin();
}
S = $(shell u.cp.s)
include $S/../conf.mk
include $S/../make/example.mk
main: main.o
install: main; u.install main $(BIN)
clean:; rm -f main main.o
.PHONY: install clean
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <mpi.h>
#include <conf.h>
#include "inc/conf.h"
#include "inc/def.h"
#include "inc/type.h"
#include "inc/dev.h"
#include "coords/type.h"
#include "coords/ini.h"
#include "utils/imp.h"
#include "utils/msg.h"
#include "utils/error.h"
#include "utils/texo.h"
#include "utils/cc.h"
#include "utils/mc.h"
#include "d/api.h"
#include "rbc/params/imp.h"
#include "rbc/type.h"
#include "rbc/imp.h"
#include "rbc/force/rnd/imp.h"
#include "rbc/force/imp.h"
#include "io/mesh_read/imp.h"
#include "mpi/glb.h"
#include "mpi/wrapper.h"
#include "conf/imp.h"
static void write0(Particle p, Force f0) {
enum {X, Y, Z};
float *r, *f;
r = p.r;
f = f0.f;
printf("%g %g %g %g %g %g\n", r[X], r[Y], r[Z], f[X], f[Y], f[Z]);
}
static void write1(int n, Particle *p, Force *f) {
int i;
for (i = 0; i < n; i++) write0(p[i], f[i]);
}
static void write(int n, Particle *p, Force *f) {
Particle *p_hst;
Force *f_hst;
EMALLOC(n, &p_hst);
EMALLOC(n, &f_hst);
cD2H(p_hst, p, n);
cD2H(f_hst, f, n);
write1(n, p_hst, f_hst);
EFREE(p_hst);
EFREE(f_hst);
}
static void run0(float dt, RbcQuants *q, RbcForce *t, const RbcParams *par, Force *f) {
rbc_force_apply(t, par, dt, q, /**/ f);
write(q->n, q->pp, f);
}
static void run1(float dt, RbcQuants *q, RbcForce *t, const RbcParams *par) {
Force *f;
Dalloc(&f, q->n);
Dzero(f, q->n);
run0(dt, q, t, par, f);
Dfree(f);
}
static void run2(const Config *cfg, MPI_Comm cart, float dt, const Coords *coords, MeshRead *off, const char *ic, long seed, const RbcParams *par, RbcQuants *q) {
RbcForce *t;
UC(rbc_gen_mesh(coords, cart, off, ic, /**/ q));
UC(rbc_gen_freeze(cart, /**/ q));
UC(rbc_force_ini(off, /**/ &t));
UC(rbc_force_set_conf(off, cfg, "rbc", t));
UC(run1(dt, q, t, par));
UC(rbc_force_fin(t));
}
void run(const Config *cfg, MPI_Comm cart, float dt, const Coords *coords, const char *cell, const char *ic, long seed, const RbcParams *par) {
MeshRead *off;
RbcQuants q;
UC(mesh_read_ini_off(cell, /**/ &off));
UC(rbc_ini(MAX_CELL_NUM, false, off, &q));
UC(run2(cfg, cart, dt, coords, off, ic, seed, par, &q));
UC(rbc_fin(&q));
UC(mesh_read_fin(off));
}
int main(int argc, char **argv) {
int seed;
float dt;
Config *cfg;
Coords *coords;
RbcParams *par;
const char *cell, *ic;
MPI_Comm cart;
int dims[3];
m::ini(&argc, &argv);
m::get_dims(&argc, &argv, dims);
m::get_cart(MPI_COMM_WORLD, dims, &cart);
UC(conf_ini(&cfg));
UC(conf_read(argc, argv, cfg));
UC(conf_lookup_float(cfg, "time.dt", &dt));
UC(coords_ini_conf(cart, cfg, &coords));
UC(conf_lookup_string(cfg, "rbc.cell", &cell));
UC(conf_lookup_string(cfg, "rbc.ic", &ic));
UC(conf_lookup_int(cfg, "rbc.seed", &seed));
UC(rbc_params_ini(&par));
UC(rbc_params_set_conf(cfg, "rbc", par));
UC(run(cfg, cart, dt, coords, cell, ic, seed, par));
UC(rbc_params_fin(par));
UC(conf_fin(cfg));
UC(coords_fin(coords));
MC(m::Barrier(cart));
m::fin();
}
S = $(shell u.cp.s)
include $S/../conf.mk
include $S/../make/example.mk
main: main.o
install: main; u.install main $(BIN)
clean:; rm -f main main.o
.PHONY: install clean
#include <mpi.h>
#include <stdio.h>
#include "utils/mc.h"
#include "utils/msg.h"
#include "mpi/glb.h"
#include "mpi/wrapper.h"
#include "utils/mc.h"
#include "utils/error.h"
#include "conf/imp.h"
#include "io/mesh_read/imp.h"
#include "mesh/gen/matrices/imp.h"
#include "mesh/gen/imp.h"
#include "mesh/area/imp.h"
#include "mesh/volume/imp.h"
#include "algo/vectors/imp.h"
#include "utils/imp.h"
#include "inc/type.h"
#define MAX_N 99999
#define MAX_M 20
static Particle pp[MAX_N];
static double output[MAX_M];
enum {AREA, VOLUME};
struct MeshQuant {
int type;
union {
MeshArea *area;
MeshVolume *volume;
};
};
static void q_ini(const char *type, MeshRead *mesh, /**/ MeshQuant **pq) {
MeshQuant *q;
EMALLOC(1, &q);
if (same_str(type, "area")) {
q->type = AREA;
mesh_area_ini(mesh, &q->area);
} else if (same_str(type, "volume")) {
q->type = VOLUME;
mesh_volume_ini(mesh, &q->volume);
} else
ERR("unknown type '%s'", type);
*pq = q;
}
static void q_apply(MeshQuant *q, int nm, Vectors *positions, double *out) {
if (q->type == AREA)
UC(mesh_area_apply(q->area, nm, positions, /**/ out));
else if (q->type == VOLUME)
UC(mesh_volume_apply(q->volume, nm, positions, /**/ out));
else ERR("unknown q->type");
}
static void q_fin(MeshQuant *q) {
if (q->type == AREA) mesh_area_fin(q->area);
else if (q->type == VOLUME) mesh_volume_fin(q->volume);
else ERR("unknown q->type");
EFREE(q);
}
void main0(const char *cell, const char *ic, const char *quant) {
int i, nm, n, nv;
Matrices *matrices;
MeshRead *mesh;
MeshQuant *mesh_quant;
Vectors *positions;
const float *verts;
UC(mesh_read_ini_off(cell, /**/ &mesh));
UC(matrices_read(ic, &matrices));
nv = mesh_read_get_nv(mesh);
verts = mesh_read_get_vert(mesh);
mesh_gen_from_matrices(nv, verts, matrices, /**/ &n, pp);
nm = n / nv;
vectors_postions_ini(n, pp, /**/ &positions);
UC(q_ini(quant, mesh, &mesh_quant));
UC(q_apply(mesh_quant, nm, positions, /**/ output));
for (i = 0; i < nm; i++)
printf("%g\n", output[i]);
UC(vectors_fin(positions));
UC(q_fin(mesh_quant));
UC(matrices_fin(matrices));
UC(mesh_read_fin(mesh));
}
int main(int argc, char **argv) {
const char *cell, *ic, *quant;
Config *cfg;
int rank, size, dims[3];
MPI_Comm cart;
m::ini(&argc, &argv);
m::get_dims(&argc, &argv, dims);
m::get_cart(MPI_COMM_WORLD, dims, &cart);
MC(m::Comm_rank(cart, &rank));
MC(m::Comm_size(cart, &size));
UC(conf_ini(&cfg));
UC(conf_read(argc, argv, cfg));
UC(conf_lookup_string(cfg, "cell", &cell));
UC(conf_lookup_string(cfg, "ic", &ic));
UC(conf_lookup_string(cfg, "q", &quant));
main0(cell, ic, quant);
UC(conf_fin(cfg));
MC(m::Barrier(cart));
m::fin();
}
S = $(shell u.cp.s)
include $S/../conf.mk
include $S/../make/example.mk
main: main.o
install: main; u.install main $(BIN)
clean:; rm -f main main.o
.PHONY: install clean
#include <stdio.h>
#include <assert.h>
#include <mpi.h>
#include <conf.h>
#include "inc/conf.h"
#include "utils/error.h"
#include "utils/imp.h"
#include "d/api.h"
#include "utils/msg.h"
#include "inc/def.h"
#include "inc/type.h"
#include "inc/dev.h"
#include "conf/imp.h"
#include "utils/texo.h"
#include "utils/cc.h"
#include "coords/type.h"
#include "rbc/params/imp.h"
#include "rbc/type.h"
#include "rbc/force/area_volume/imp.h"
#include "rbc/imp.h"
#include "rbc/force/rnd/imp.h"
#include "rbc/force/imp.h"
#include "rbc/stretch/imp.h"
#include "scheme/move/imp.h"
#include "scheme/force/imp.h"
#include "scheme/time_line/imp.h"
#include "io/mesh/imp.h"
#include "io/diag/part/imp.h"
#include "io/mesh_read/imp.h"
#include "mpi/wrapper.h"
#include "mpi/glb.h"
#include "imp.h"
#include "imp/main.h"
void run(const Config *cfg, MPI_Comm cart, float dt, float mass, float te,
const Coords*, float part_freq, const BForce*,
const char *cell, const char *ic, const RbcParams*);
static void garea_volume(RbcQuants *q, /**/ float *a, float *v) {
int nc;
AreaVolume *area_volume;
const Particle *pp;
float hst[2], *dev;
nc = q->nc; pp = q->pp; area_volume = q->area_volume;
UC(area_volume_compute(area_volume, nc, pp, /**/ &dev));
cD2H(hst, dev, 2);
*a = hst[0]; *v = hst[1];
}
static void dump(MPI_Comm cart, DiagPart *diagpart, float dt, const Coords *coords, RbcQuants *q, MeshWrite *mesh_write) {
int n;
Particle *pp;
float area, volume, area0, volume0;
static int i = 0;
n = q->nc * q->nv;
EMALLOC(n, &pp);