static void run_pick_surface_c(struct mesh_menu_val *mesh_m){
	char file_head[LENGTHBUF];
	char file_tmp[LENGTHBUF];
	char file_ext[LENGTHBUF];
	char command[LENGTHBUF];
    
    if (mesh_m->iformat_surface_mesh == IFLAG_FULL_MESH_GZ) {
        kemoview_get_ext_from_file_name(mesh_m->mesh_file_name, file_head, file_ext);
    } else {
        strngcopy(file_head, mesh_m->mesh_file_name);
    };
    kemoview_get_ext_from_file_name(file_head, file_tmp, file_ext);
    kemoview_get_ext_from_file_name(file_tmp, file_head, file_ext);
    
	strcpy(command,mesh_m->pick_surface_command);
	strcat(command, "    ");
	strcat(command, file_head);
	printf("pick surface command line: %s\n", command);
	system(command);
    
    if (mesh_m->iformat_surface_mesh == IFLAG_FULL_MESH_GZ) {
        sprintf(mesh_m->mesh_file_name, "%s.ksm.gz",file_head);
        mesh_m->iformat_surface_mesh = IFLAG_SURF_MESH_GZ;
    } else {
        sprintf(mesh_m->mesh_file_name, "%s.ksm",file_head);
        mesh_m->iformat_surface_mesh = IFLAG_SURF_MESH;
    };
	return;
}
int main(int argc,char *argv[])
{
	struct SGS_MHD_control_c *mhd_ctl;
	char buf[LENGTHBUF];      /* character buffer for reading line */
	char file_name[LENGTHBUF] = "/Users/matsui/work/C_test/control_MHD";
	char file_name_2[LENGTHBUF];
    char fld_name[NCHARA_FIELD];
    char fld_math[KCHARA_C];
	int i;
    
    int num_comps;
	
    all_fld_list = (struct all_field_ctl_c **) malloc(NUM_FIELD * sizeof(struct all_field_ctl_c *));
    alloc_all_field_ctl_c(all_fld_list);
		
    printf("baka %d\n", NUM_FIELD);
	for(i=0;i<NUM_FIELD;i++){
        num_comps = get_field_properties(i, fld_name, fld_math);
		printf("field_name %d: %s %d %s\n", i, fld_name, num_comps, fld_math);
	}
	
	/*
	if (argc <= 1) {
		printf("Input control file in standard input. \n");
		return 1;
	};
	strngcopy(file_name, argv[1]);
    */
	strngcopy(file_name_2, file_name);
	strcat(file_name_2, "_2");
	
	printf("Input file name: %s\n", file_name);
	printf("Copied file name: %s\n", file_name_2);
	
	
	mhd_ctl = (struct SGS_MHD_control_c *) malloc(sizeof(struct SGS_MHD_control_c));
	alloc_SGS_MHD_control_c(mhd_ctl);
	
	read_SGS_MHD_control_file_c(file_name, buf, mhd_ctl);

    load_field_w_qflag_from_ctl(mhd_ctl->model_ctl->fld_ctl, all_fld_list);
    
    write_SGS_MHD_control_file_c(file_name_2, mhd_ctl);

    rename_SGS_MHD_ctl_subfile_c(mhd_ctl);
    write_SGS_MHD_ctl_subfile_c(mhd_ctl);

    dealloc_SGS_MHD_control_c(mhd_ctl);
    
    for(i=0;i<NUM_FIELD;i++){
        printf("%d:, %s: %s: %d %d %d\n", i, all_fld_list[i]->field_name,
               all_fld_list[i]->field_math, all_fld_list[i]->iflag_use,
               all_fld_list[i]->iflag_viz, all_fld_list[i]->iflag_monitor);
    };
    dealloc_all_field_ctl_c(all_fld_list);
    
	free(mhd_ctl);
	
	return 0;
}
static void init_draw_fline(struct mesh_menu_val *mesh_m,
                            struct psf_data *fline_d, struct fline_menu_val *fline_m, 
                            struct psf_data *ucd_tmp, struct ucd_file_menu_val *ucd_m){
    
	strngcopy(fline_m->fline_header, ucd_m->ucd_header);
	fline_m->fline_step = ucd_m->ucd_step;
	set_kemoview_fline_data(fline_d, ucd_tmp, mesh_m, fline_m);
    return;
};
static void init_draw_psf(struct mesh_menu_val *mesh_m, struct kemo_array_control *psf_a,
                          struct psf_data **psf_d, struct psf_menu_val **psf_m, 
                          struct psf_data *ucd_tmp, struct ucd_file_menu_val *ucd_m){
    int id_load;
    id_load = add_new_kemoview_array(psf_a);
	strngcopy(psf_m[id_load]->psf_header, ucd_m->ucd_header);
	psf_m[id_load]->psf_step = ucd_m->ucd_step;
	
	if(psf_a->num_loaded == psf_a->nlimit_loaded){
		dealloc_draw_psf_flags(psf_d[id_load], psf_m[id_load]);
		deallc_all_psf_data(psf_d[id_load]);
	};
	
	set_kemoview_psf_data(psf_d[id_load], ucd_tmp, mesh_m, psf_m[id_load]);
    return;
};
void get_label_equations_ctl(int index, char *label){
    if(index < NLBL_EQUATIONS_CTL) strngcopy(label, label_equations_ctl[index]);
    return;
};
void get_label_dimless_ctl(int index, char *label){
    if(index < NLBL_DIMLESS_CTL) strngcopy(label, label_dimless_ctl[index]);
    return;
};
void get_label_comp_equation_ctl(int index, char *label){
    if(index < NLBL_HEAT_EQ_CTL) strngcopy(label, label_comp_equation_ctl[index]);
    return;
};
void get_label_induction_equation_ctl(int index, char *label){
    if(index < NLBL_INDUCTION_EQ_CTL) strngcopy(label, label_induction_equation_ctl[index]);
    return;
};
void get_label_momentum_equation_ctl(int index, char *label){
    if(index < NLBL_MOMENTUM_EQ_CTL) strngcopy(label, label_momentum_equation_ctl[index]);
    return;
};
Exemplo n.º 10
0
void send_each_psf_data_name(struct psf_data *psf_d, char *name, int i){strngcopy(name, psf_d->data_name[i]);};
Exemplo n.º 11
0
int send_each_psf_file_header_full(struct psf_menu_val *psf_menu, char *file_head, int *iflag){
	*iflag = psf_menu->iflag_psf_file;
	strngcopy(file_head, psf_menu->psf_header);
	return psf_menu->psf_step;
};
static int set_kemoview_data_fmt_flag(const char *file_name, char *file_head){
	int ifile_type;
	char file_head2[LENGTHBUF];
	char file_ext[LENGTHBUF];
	
	kemoview_get_ext_from_file_name(file_name, file_head, file_ext);
	
	if((file_ext[0] == 'g' && file_ext[1] == 'z') 
       || (file_ext[0] == 'G' && file_ext[1] == 'Z') ){
        kemoview_get_ext_from_file_name(file_head, file_head2, file_ext);

        if((file_ext[0] == 'k' && file_ext[1] == 's' && file_ext[2] == 'm')
           || (file_ext[0] == 'K' && file_ext[1] == 'S' && file_ext[2] == 'M') ){
            ifile_type = IFLAG_SURF_MESH_GZ;
        } else if((file_ext[0] == 'g' && file_ext[1] == 'f' && file_ext[2] == 'm')
                  || (file_ext[0] == 'G' && file_ext[1] == 'F' && file_ext[2] == 'M') ){
            ifile_type = IFLAG_FULL_MESH_GZ;
            kemoview_get_ext_from_file_name(file_head2, file_head, file_ext);
            strngcopy(file_head2, file_head);
        } else if((file_ext[0] == 'u' && file_ext[1] == 'd' && file_ext[2] == 't')
                  || (file_ext[0] == 'U' && file_ext[1] == 'D' && file_ext[2] == 'T') ){
            ifile_type = IFLAG_SURF_UDT_GZ;
        } else if((file_ext[0] == 'i' && file_ext[1] == 'n' && file_ext[2] == 'p')
                  ||	  (file_ext[0] == 'I' && file_ext[1] == 'N' && file_ext[2] == 'P') ){
            ifile_type = IFLAG_SURF_UCD_GZ;
        } else if((file_ext[0] == 'v' && file_ext[1] == 't' && file_ext[2] == 'd')
                  ||	  (file_ext[0] == 'V' && file_ext[1] == 'T' && file_ext[2] == 'D') ){
            ifile_type = IFLAG_SURF_VTD_GZ;
        } else if(	  (file_ext[0] == 'v' && file_ext[1] == 't' && file_ext[2] == 'k')
                  ||	  (file_ext[0] == 'V' && file_ext[1] == 'T' && file_ext[2] == 'K') ){
            ifile_type = IFLAG_SURF_VTK_GZ;

        } else {
            ifile_type = 99;

        };

        strngcopy(file_head, file_head2);
            
        } else if(	  (file_ext[0] == 'k' && file_ext[1] == 's' && file_ext[2] == 'm')
                  ||	  (file_ext[0] == 'K' && file_ext[1] == 'S' && file_ext[2] == 'M') ){
            ifile_type = IFLAG_SURF_MESH;
        } else if(    (file_ext[0] == 'g' && file_ext[1] == 'f' && file_ext[2] == 'm')
                  ||	  (file_ext[0] == 'G' && file_ext[1] == 'F' && file_ext[2] == 'M') ){
            ifile_type = IFLAG_FULL_MESH;

            kemoview_get_ext_from_file_name(file_head, file_head2, file_ext);
            strngcopy(file_head, file_head2);
        } else if(	  (file_ext[0] == 'u' && file_ext[1] == 'd' && file_ext[2] == 't')
                  ||	  (file_ext[0] == 'U' && file_ext[1] == 'D' && file_ext[2] == 'T') ){
            ifile_type = IFLAG_SURF_UDT;
        } else if(	  (file_ext[0] == 'i' && file_ext[1] == 'n'  && file_ext[2] == 'p')
                  ||	  (file_ext[0] == 'I' && file_ext[1] == 'N' && file_ext[2] == 'P') ){
            ifile_type = IFLAG_SURF_UCD;
        } else if(	  (file_ext[0] == 'v' && file_ext[1] == 't' && file_ext[2] == 'd')
                  ||	  (file_ext[0] == 'V' && file_ext[1] == 'T' && file_ext[2] == 'D') ){
            ifile_type = IFLAG_SURF_VTD;
        } else if(	  (file_ext[0] == 'v' && file_ext[1] == 't' && file_ext[2] == 'k')
                  ||	  (file_ext[0] == 'V' && file_ext[1] == 'T' && file_ext[2] == 'K') ){
            ifile_type = IFLAG_SURF_VTK;
        } else {
            ifile_type = 99;
        };
	return ifile_type;
}
int kemoviewer_open_data(const char *file_name, struct viewer_mesh *mesh_d, struct mesh_menu_val *mesh_m, 
                       struct kemo_array_control *psf_a, struct psf_data **psf_d, struct psf_menu_val **psf_m,
                       struct psf_data *fline_d, struct fline_menu_val *fline_m, 
                       struct psf_data *ucd_tmp, struct ucd_file_menu_val *ucd_m,
                       struct view_element *view){
	int iflag_datatype;
	int iflag_fileformat;
	char file_head[LENGTHBUF];
	
	iflag_fileformat = set_kemoview_data_fmt_flag(file_name, file_head);
	printf("iflag_fileformat %d\n", iflag_fileformat);
	printf("file_name %s\n", file_name);
    
	if(   iflag_fileformat == IFLAG_SURF_MESH || iflag_fileformat == IFLAG_SURF_MESH_GZ
       || iflag_fileformat == IFLAG_FULL_MESH || iflag_fileformat == IFLAG_FULL_MESH_GZ){
        mesh_m->iformat_surface_mesh = iflag_fileformat;
		strngcopy(mesh_m->mesh_file_name, file_name);
        
        if(iflag_fileformat == IFLAG_FULL_MESH || iflag_fileformat == IFLAG_FULL_MESH_GZ){
            run_pick_surface_c(mesh_m);
        };
        
		init_draw_mesh(mesh_d, mesh_m, view);
		iflag_datatype = IFLAG_MESH;
        
    } else if(   iflag_fileformat == IFLAG_SURF_UDT || iflag_fileformat == IFLAG_SURF_UDT_GZ
              || iflag_fileformat == IFLAG_SURF_VTD || iflag_fileformat == IFLAG_SURF_VTD_GZ){
        ucd_m->iformat_ucd_file = iflag_fileformat;
		ucd_m->ucd_step = get_index_from_file_head(file_head, ucd_m->ucd_header);
		iflag_datatype = check_gzip_psf_grd_first(ucd_m, ucd_tmp);
		if(iflag_datatype != 0){
			check_gzip_psf_udt_first(ucd_m, ucd_tmp);
			init_draw_psf(mesh_m, psf_a, psf_d, psf_m, ucd_tmp, ucd_m);
			psf_m[psf_a->id_current]->iflag_psf_file = iflag_fileformat;
		} else{
			dealloc_psf_mesh_c(ucd_tmp);
		};
        
	} else if( iflag_fileformat == IFLAG_SURF_UCD || iflag_fileformat == IFLAG_SURF_UCD_GZ
              || iflag_fileformat == IFLAG_SURF_VTK || iflag_fileformat == IFLAG_SURF_VTK_GZ){
        ucd_m->iformat_ucd_file = iflag_fileformat;
		ucd_m->ucd_step = get_index_from_file_head(file_head, ucd_m->ucd_header);
		iflag_datatype = check_gzip_kemoview_ucd_first(ucd_m, ucd_tmp);
        
		if(iflag_datatype == IFLAG_SURFACES){
			init_draw_psf(mesh_m, psf_a, psf_d, psf_m, ucd_tmp, ucd_m);
			psf_m[psf_a->id_current]->iflag_psf_file = iflag_fileformat;
		} else if(iflag_datatype == IFLAG_LINES){
			init_draw_fline(mesh_m, fline_d, fline_m, ucd_tmp, ucd_m);
		} else {
			dealloc_psf_data_s(ucd_tmp);
			dealloc_psf_mesh_c(ucd_tmp);
		}
	} else {
		iflag_datatype = 0;
	};
    
    if ( mesh_m->iflag_draw_mesh == IZERO ) {
        cal_psf_viewer_range(psf_d, psf_a, fline_d, fline_m, view);
        reset_light_by_size_of_domain(view->r_max);
        reset_to_init_angle(view);
    };
	return iflag_datatype;
}
Exemplo n.º 14
0
void get_label_field_ctl(int index, char *label){
    if(index < NLBL_FIELD_CTL) strngcopy(label, label_field_ctl[index]);
    return;
};
void get_label_mhd_evo_area_ctl(int index, char *label){
    if(index < NLBL_MHD_EVO_AREA_CTL) strngcopy(label, label_mhd_evo_area_ctl[index]);
    return;
};
void get_label_mhd_evolution_ctl(int index, char *label){
    if(index < NLBL_MHD_EVOLUTION_CTL) strngcopy(label, label_mhd_evolution_ctl[index]);
    return;
};