Commit a63f40a9 authored by tilman.metz's avatar tilman.metz

created new folder genmod for model functions

some changes on Makefile had to be done to outsource functions from the main code
parent dba63f25
......@@ -4,4 +4,5 @@
*.backup
*~*
*.orig
*.o
manual_IFOS3D.pdf
/*
* Model defined by flnode file.
*/
#include "fd.h"
void model(st_model *mod){
/*--------------------------------------------------------------------------*/
/* extern variables */
extern int NX, NY,NZ, NXG, NYG, NZG, POS[4], MYID;
extern float DZ;
extern FILE *FP;
/* local variables */
float muv, piv, vp, vs, rhov;
int i, j,k, ii, jj,kk, l;
FILE *flfile;
int nodes;
char cline[256];
float *fldepth, *flrho, *flvp, *flvs;
nodes=7;
fldepth=vector(1,nodes);
flrho=vector(1,nodes);
flvp=vector(1,nodes);
flvs=vector(1,nodes);
/*read FL nodes from File*/
flfile=fopen("flnodes/flnodes.rheinstetten","r");
if (flfile==NULL) err(" FL-file could not be opened !");
for (l=1;l<=nodes;l++){
fgets(cline,255,flfile);
if (cline[0]!='#'){
sscanf(cline,"%f%f%f%f",&fldepth[l], &flrho[l], &flvp[l], &flvs[l]);
}
else l=l-1;
}
if(MYID==0){
fprintf(FP," ------------------------------------------------------------------ \n\n");
fprintf(FP," Information of FL nodes: \n\n");
fprintf(FP," \t depth \t rho \t vp \t vs \n\n");
for (l=1;l<=nodes;l++){
fprintf(FP," \t %f \t %f \t %f \t %f\n\n",fldepth[l],flrho[l],flvp[l],flvs[l]);
}
fprintf(FP," ------------------------------------------------------------------ \n\n");
}
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* loop over global grid */
for (i=1;i<=NXG;i++){
for (k=1; k<=NZG; k++) {
for (l=1;l<nodes;l++){
if (fldepth[l]==fldepth[l+1]){
if ((i==1) && (k==1) && (MYID==0)){
fprintf(FP,"depth: %f m: double node\n",fldepth[l]);}}
else{
for (j=(int)(fldepth[l]/DZ)+1;j<=(int)(fldepth[l+1]/DZ);j++){
vp=0.0; vs=0.0; rhov=0.0;
vp=(DZ*(j-1)-fldepth[l])*(flvp[l+1]-flvp[l])/(fldepth[l+1]-fldepth[l])+flvp[l];
vp=vp*1000.0;
vs=(DZ*(j-1)-fldepth[l])*(flvs[l+1]-flvs[l])/(fldepth[l+1]-fldepth[l])+flvs[l];
vs=vs*1000.0;
rhov=(DZ*(j-1)-fldepth[l])*(flrho[l+1]-flrho[l])/(fldepth[l+1]-fldepth[l])+flrho[l];
rhov=rhov*1000.0;
muv=vs*vs*rhov;
piv=vp*vp*rhov;
/* only the PE which belongs to the current global gridpoint
is saving model parameters in his local arrays */
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY)) &&
(POS[3]==((k-1)/NZ))) {
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
kk=k-POS[3]*NZ;
mod->u[jj][ii][kk]=muv;
mod->rho[jj][ii][kk]=rhov;
mod->pi[jj][ii][kk]=piv;
}
}
}
}
for (j=(int)(fldepth[nodes]/DZ)+1;j<=NYG;j++){
vp=0.0; vs=0.0; rhov=0.0;
vp=flvp[nodes]*1000.0; vs=flvs[nodes]*1000.0; rhov=flrho[nodes]*1000.0;
muv=vs*vs*rhov;
piv=vp*vp*rhov;
/* only the PE which belongs to the current global gridpoint
is saving model parameters in his local arrays */
if ((POS[1]==((i-1)/NX)) &&
(POS[2]==((j-1)/NY)) &&
(POS[3]==((k-1)/NZ))) {
ii=i-POS[1]*NX;
jj=j-POS[2]*NY;
kk=k-POS[3]*NZ;
mod->u[jj][ii][kk]=muv;
mod->rho[jj][ii][kk]=rhov;
mod->pi[jj][ii][kk]=piv;
}
}
}
}
free_vector(fldepth,1,nodes);
free_vector(flrho,1,nodes);
free_vector(flvp,1,nodes);
free_vector(flvs,1,nodes);
}
......@@ -205,7 +205,7 @@ caxis([caxis_value_1 caxis_value_2])
set(gca,'ydir','normal');
xlabel('x in m','FontSize',fontsize)
ylabel('z in m','FontSize',fontsize)
title(['true ' parameter '-model. Slize at x=' num2str(sly) 'm'],'FontSize',fontsize)
title(['true ' parameter '-model. Slize at y=' num2str(sly) 'm'],'FontSize',fontsize)
axis tight
hold on
%Plot sources if in model slice
......@@ -236,7 +236,7 @@ caxis([caxis_value_1 caxis_value_2])
set(gca,'ydir','normal');
xlabel('x in m','FontSize',fontsize)
ylabel('z in m','FontSize',fontsize)
title([parameter '-model. Iteration ' num2str(iteration) ' Slize at x=' num2str(sly) 'm'],'FontSize',fontsize)
title([parameter '-model. Iteration ' num2str(iteration) ' Slize at y=' num2str(sly) 'm'],'FontSize',fontsize)
axis tight
hold on
%Plot sources if in model slice
......@@ -267,7 +267,7 @@ set(gca,'ydir','normal');
%set(gca,'xdir','reverse');
xlabel('x in m','FontSize',fontsize)
ylabel('y in m','FontSize',fontsize)
title(['true ' parameter '-model. Slize at x=' num2str(slz) 'm'],'FontSize',fontsize)
title(['true ' parameter '-model. Slize at z=' num2str(slz) 'm'],'FontSize',fontsize)
axis tight
hold on
%Plot sources if in model slice
......@@ -298,7 +298,7 @@ set(gca,'ydir','normal');
%set(gca,'xdir','reverse');
xlabel('x in m','FontSize',fontsize)
ylabel('y in m','FontSize',fontsize)
title([parameter '-model. Iteration ' num2str(iteration) ' Slize at x=' num2str(slz) 'm'],'FontSize',fontsize)
title([parameter '-model. Iteration ' num2str(iteration) ' Slize at z=' num2str(slz) 'm'],'FontSize',fontsize)
axis tight
hold on
%Plot sources if in model slice
......
# run forward simulation to obtain observed data
make clean
make install MODEL=hh_toy_true.c
make install MODEL=../genmod/hh_toy_true.c
mpirun -np 8 nice -19 ../bin/ifos3d ./in_and_out/ifos3d_toy_FW.json | tee ./in_and_out/ifos3D.out
cp model/toy.vs_it0 model/toy.vs.true
......@@ -10,5 +10,5 @@ cp model/toy.rho_it0 model/toy.rho.true
# invert observed data using homogeneous starting model
make clean
make install MODEL=hh_toy_start.c
mpirun -np 8 nice -19 ../bin/ifos3d ./in_and_out/ifos3d_toy.json | tee ./in_and_out/ifos3D_INV.out
make install MODEL=../genmod/hh_toy_start.c
mpirun -np 8 nice -19 ../bin/ifos3d ./in_and_out/ifos3d_toy.json | tee ./in_and_out/ifos3D_INV.out
......@@ -8,7 +8,9 @@
# source code for model generation (elastic)
MODEL_SCR = hh_toy_true.c
MODEL_SCR = ../genmod/hh_toy_true.c
#MODEL_SCR = ../genmod/rheinstetten_elastic.c
# Compiler (LAM: CC=hcc, CRAY T3E: CC=cc, SHARCNet: mpicc)
......@@ -17,7 +19,7 @@ CC=mpicc
LFLAGS=-lm -lmpi -lcseife
CFLAGS=-Wall -O4
SFLAGS=-L./../libcseife
IFLAGS=-I./../libcseife
IFLAGS=-I./../libcseife -I.
#Hermit
#CC=cc
......@@ -44,8 +46,12 @@ IFLAGS=-I./../libcseife
# after this line, no further editing should be necessary
# --------------------------------------------------------
.c.o:
$(CC) -c $(CFLAGS) $< $(IFLAGS)
# .c.o:
# $(CC) -c $(CFLAGS) $< $(IFLAGS)
#
%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $< $(IFLAGS)
# $(CC) $(CFLAGS) -MM $*.c $(IFLAGS) > $*.d
SNAPMERGE_OBJ = $(SNAPMERGE_SCR:%.c=%.o)
......@@ -162,12 +168,15 @@ snapmerge: $(SNAPMERGE_OBJ)
# part_model: $(PARTMODEL_OBJ)
# $(CC) $(LFLAGS) $(PARTMODEL_OBJ) -o ../bin/partmodel
ifos3d: $(IFOS_OBJ)
$(CC) $(SFLAGS) $(IFOS_OBJ) $(LFLAGS) -o ../bin/ifos3d
ifos3d: $(IFOS_OBJ) fd.h
$(CC) $(SFLAGS) $(IFOS_OBJ) $(LFLAGS) -o ../bin/ifos3d
clean:
find . -name "*.o" -exec rm {} \;
find . -name "*.bck" -exec rm {} \;
find . -name "core" -exec rm {} \;
find ../genmod -name "*.o" -exec rm {} \;
find ../genmod -name "*.d" -exec rm {} \;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment