int BSSCR_create_execute_script( void )
{
       int argc;
        char **args;
        int i;
        PetscViewer viewer, viewer_dated;
        time_t      currTime;
        struct tm*  timeInfo;
        int         adjustedYear;
        int         adjustedMonth;
        char        *filename;


        /* get file name with date */
        currTime = time( NULL );
        timeInfo = localtime( &currTime );
        /* See man localtime() for why to adjust these */
        adjustedYear = 1900 + timeInfo->tm_year;
        adjustedMonth = 1 + timeInfo->tm_mon;
        /* Format; name-YYYY.MM.DD-HH.MM.SS.sh */
        asprintf( &filename, "%s-%.4d.%.2d.%.2d-%.2d.%.2d.%.2d.%s",
                        "execute-job",
                        adjustedYear, adjustedMonth, timeInfo->tm_mday,
                        timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec ,
                        "sh" );

        PetscViewerASCIIOpen( PETSC_COMM_SELF, filename, &viewer_dated );


        /* get file name without */
        PetscViewerASCIIOpen( PETSC_COMM_SELF, "execute-job.sh", &viewer );


        /* ouput what the command line arguments were */
        PetscGetArgs( &argc, &args );

        for( i=0; i<argc; i++ ) {
                PetscViewerASCIIPrintf( viewer, "%s ", args[i] );
                PetscViewerASCIIPrintf( viewer_dated, "%s ", args[i] );
        }


        Stg_PetscViewerDestroy(&viewer);
        Stg_PetscViewerDestroy(&viewer_dated);
        free( filename );


        return 0;

}
Ejemplo n.º 2
0
void bsscr_dirwriteVec(Vec V, char name[], char dir[], char message[]){
    PetscViewer             vec_view_file;
    char str[100];
    PetscTruth dump=PETSC_FALSE;
    PetscOptionsGetTruth( PETSC_NULL ,"-dump_matvec", &dump, 0 );
    if(dump){
    if( V != NULL ) {
	PetscPrintf( PETSC_COMM_WORLD,"%s \n",message);
	PetscObjectSetName((PetscObject)V,name);
	sprintf(str,"%s%svectorBin",dir,name);
	PetscViewerBinaryOpen( PETSC_COMM_WORLD, str, FILE_MODE_WRITE, &vec_view_file );
	PetscViewerSetFormat( vec_view_file, PETSC_VIEWER_NATIVE );
	VecView( V, vec_view_file );
	Stg_PetscViewerDestroy(&vec_view_file );
	sprintf(str,"%s%svector.m",dir,name);
	PetscViewerASCIIOpen( PETSC_COMM_WORLD, str, &vec_view_file );
	PetscViewerSetFormat( vec_view_file, PETSC_VIEWER_ASCII_MATLAB );
	VecView( V, vec_view_file );
	Stg_PetscViewerDestroy(&vec_view_file );
    }
    }
}
Ejemplo n.º 3
0
void bsscr_writeMat(Mat K, char name[], char message[]){
    PetscViewer             mat_view_file;
    char str[100];
    PetscTruth dump=PETSC_FALSE;
    PetscOptionsGetTruth( PETSC_NULL ,"-dump_matvec", &dump, 0 );
    if(dump){
    if( K != NULL ) {
	PetscPrintf( PETSC_COMM_WORLD,"%s \n",message);
	PetscObjectSetName((PetscObject)K,name);
	sprintf(str,"%smatrixBin",name);
	PetscViewerBinaryOpen( PETSC_COMM_WORLD, str, FILE_MODE_WRITE, &mat_view_file );
	PetscViewerSetFormat( mat_view_file, PETSC_VIEWER_NATIVE );
	MatView( K, mat_view_file );
	Stg_PetscViewerDestroy(&mat_view_file );
	sprintf(str,"%smatrix.m",name);
	PetscViewerASCIIOpen( PETSC_COMM_WORLD, str, &mat_view_file );
	PetscViewerSetFormat( mat_view_file, PETSC_VIEWER_ASCII_MATLAB );
	MatView( K, mat_view_file );
	Stg_PetscViewerDestroy(&mat_view_file );
    }
    }
}
PetscErrorCode BSSCR_StokesCreateOperatorSummary( Mat K, Mat G, Mat C, Vec f, Vec h, const char filename[] )
{
	MPI_Comm comm;
	PetscViewer v;
	char op_name[PETSC_MAX_PATH_LEN];	
	PetscTruth flg;
	
	PetscObjectGetComm( (PetscObject)K, &comm );
	PetscViewerASCIIOpen( comm, filename, &v );
	
	BSSCR_GeneratePetscHeader_for_viewer( v );
	PetscViewerASCIIPrintf( v, "\nInput matrices:\n");
	PetscViewerASCIIPushTab(v);
	
	PetscOptionsGetString( PETSC_NULL,"-stokes_A11",op_name,PETSC_MAX_PATH_LEN-1,&flg );
	if (flg) {	PetscViewerASCIIPrintf( v, "A11: %s\n", op_name );	}
	
	PetscOptionsGetString( PETSC_NULL,"-stokes_A12",op_name,PETSC_MAX_PATH_LEN-1,&flg );
	if (flg) {	PetscViewerASCIIPrintf( v, "A12: %s\n", op_name );	}
	
	PetscOptionsGetString( PETSC_NULL,"-stokes_A22",op_name,PETSC_MAX_PATH_LEN-1,&flg );
	if (flg) {	PetscViewerASCIIPrintf( v, "A22: %s\n", op_name );	}
	
	PetscOptionsGetString( PETSC_NULL,"-stokes_Smat",op_name,PETSC_MAX_PATH_LEN-1,&flg );
	if (flg) {	PetscViewerASCIIPrintf( v, "Smat: %s\n", op_name );	}
	
	PetscOptionsGetString( PETSC_NULL,"-stokes_b1",op_name,PETSC_MAX_PATH_LEN-1,&flg );
	if (flg) {	PetscViewerASCIIPrintf( v, "b1: %s\n", op_name );	}
	
	PetscOptionsGetString( PETSC_NULL,"-stokes_b2",op_name,PETSC_MAX_PATH_LEN-1,&flg );
	if (flg) {	PetscViewerASCIIPrintf( v, "b2: %s\n", op_name );	}
	
	PetscViewerASCIIPopTab(v);
	PetscViewerASCIIPrintf( v, "\n");
	
	BSSCR_MatInfoLog(v,K,"stokes_A11");			PetscViewerASCIIPrintf( v, "\n");
	
	BSSCR_MatInfoLog(v,G,"stokes_A12");			PetscViewerASCIIPrintf( v, "\n");
	if (C) { BSSCR_MatInfoLog(v,C,"stokes_A22"); 		PetscViewerASCIIPrintf( v, "\n");	}	
	
	BSSCR_VecInfoLog(v,f,"stokes_b1");			PetscViewerASCIIPrintf( v, "\n");
	BSSCR_VecInfoLog(v,h,"stokes_b2");			PetscViewerASCIIPrintf( v, "\n");
	
	Stg_PetscViewerDestroy(&v );
	
	PetscFunctionReturn(0);
}