added LF=UNIX to a bunch of files

This commit is contained in:
Martin Diehl 2012-02-22 13:30:00 +00:00
parent d8ffc29236
commit d68a3d1869
11 changed files with 730 additions and 723 deletions

28
LICENSE
View File

@ -1,14 +1,14 @@
Copyright 2011 Max-Planck-Institut für Eisenforschung GmbH Copyright 2011 Max-Planck-Institut für Eisenforschung GmbH
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.

14
README
View File

@ -1,8 +1,8 @@
CONTACT INFORMATION CONTACT INFORMATION
Max-Planck-Institut für Eisenforschung GmbH Max-Planck-Institut für Eisenforschung GmbH
Max-Planck-Str. 1 Max-Planck-Str. 1
40237 Düsseldorf 40237 Düsseldorf
Germany Germany
DAMASK@mpie.de DAMASK@mpie.de

View File

@ -127,7 +127,6 @@ subroutine DAMASK_interface_init()
loadcaseParameter = '' ! should be empty loadcaseParameter = '' ! should be empty
loadcaseParameter(1:length)=commandLine(start:start+length) loadcaseParameter(1:length)=commandLine(start:start+length)
print*, loadcaseParameter
do i=1,len(commandLine) ! remove capitals do i=1,len(commandLine) ! remove capitals
if(64<iachar(commandLine(i:i)) .and. iachar(commandLine(i:i))<91) commandLine(i:i)& if(64<iachar(commandLine(i:i)) .and. iachar(commandLine(i:i))<91) commandLine(i:i)&
= achar(iachar(commandLine(i:i))+32) = achar(iachar(commandLine(i:i))+32)

View File

@ -592,7 +592,7 @@ do while (any(crystallite_subStep(:,:,FEsolving_execELem(1):FEsolving_execElem(2
#ifndef _OPENMP #ifndef _OPENMP
if (debug_verbosity > 4 & if (debug_verbosity > 4 &
.and. ((e == debug_e .and. i == debug_i .and. g == debug_g) .or. .not. debug_selectiveDebugger)) then .and. ((e == debug_e .and. i == debug_i .and. g == debug_g) .or. .not. debug_selectiveDebugger)) then
write(6,'(a,f10.8,a,f10.8,a)') '<< CRYST >> winding forward from ', & write(6,'(a,f12.8,a,f12.8,a)') '<< CRYST >> winding forward from ', &
crystallite_subFrac(g,i,e),' to current crystallite_subfrac ', & crystallite_subFrac(g,i,e),' to current crystallite_subfrac ', &
crystallite_subFrac(g,i,e)+crystallite_subStep(g,i,e),' in crystallite_stressAndItsTangent' crystallite_subFrac(g,i,e)+crystallite_subStep(g,i,e),' in crystallite_stressAndItsTangent'
write(6,*) write(6,*)
@ -637,7 +637,7 @@ do while (any(crystallite_subStep(:,:,FEsolving_execELem(1):FEsolving_execElem(2
#ifndef _OPENMP #ifndef _OPENMP
if (debug_verbosity > 4_pInt & if (debug_verbosity > 4_pInt &
.and. ((e == debug_e .and. i == debug_i .and. g == debug_g) .or. .not. debug_selectiveDebugger)) then .and. ((e == debug_e .and. i == debug_i .and. g == debug_g) .or. .not. debug_selectiveDebugger)) then
write(6,'(a,f10.8)') '<< CRYST >> cutback step in crystallite_stressAndItsTangent with new crystallite_subStep: ',& write(6,'(a,f12.8)') '<< CRYST >> cutback step in crystallite_stressAndItsTangent with new crystallite_subStep: ',&
crystallite_subStep(g,i,e) crystallite_subStep(g,i,e)
write(6,*) write(6,*)
endif endif

View File

@ -182,7 +182,6 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
-fall-intrinsics\ -fall-intrinsics\
-pedantic\ -pedantic\
-Warray-bounds\ -Warray-bounds\
-Wunused-parameter\
-Wampersand\ -Wampersand\
-Wno-tabs\ -Wno-tabs\
-Wcharacter-truncation\ -Wcharacter-truncation\
@ -190,9 +189,14 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
-Waliasing\ -Waliasing\
-Wconversion\ -Wconversion\
-Wsurprising\ -Wsurprising\
-Wunused-value\ -Wunderflow\
-Wunderflow -Wswitch\
-Wstrict-overflow\
-Wextra\
-Wattributes\
-Wunsafe-loop-optimizations\
-Wunused
#-xf95-cpp-input: preprocessor #-xf95-cpp-input: preprocessor
#-ffree-line-length-132: restrict line length to the standard 132 characters #-ffree-line-length-132: restrict line length to the standard 132 characters
#-fno-range-check: disables checking if result can be represented by variable. Needs to be set to enable DAMASK_NaN #-fno-range-check: disables checking if result can be represented by variable. Needs to be set to enable DAMASK_NaN
@ -200,7 +204,6 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
#-fall-intrinsics: #-fall-intrinsics:
#-pedantic: more strict on standard, enables some of the warnings below #-pedantic: more strict on standard, enables some of the warnings below
#-Warray-bounds: checks if array reference is out of bounds at compile time. use -fcheck-bounds to also check during runtime #-Warray-bounds: checks if array reference is out of bounds at compile time. use -fcheck-bounds to also check during runtime
#-Wunused-parameter: find usused variables with "parameter" attribute
#-Wampersand: checks if a character expression is continued proberly by an ampersand at the end of the line and at the beginning of the new line #-Wampersand: checks if a character expression is continued proberly by an ampersand at the end of the line and at the beginning of the new line
#-Wno-tabs: do not allow tabs in source #-Wno-tabs: do not allow tabs in source
#-Wcharacter-truncation: warn if character expressions (strings) are truncated #-Wcharacter-truncation: warn if character expressions (strings) are truncated
@ -209,14 +212,20 @@ COMPILE_OPTIONS_gfortran :=-xf95-cpp-input\
#-Wconversion: warn about implicit conversions between different type #-Wconversion: warn about implicit conversions between different type
#-Wsurprising: warn when "suspicious" code constructs are encountered. While technically legal these usually indicate that an error has been made. #-Wsurprising: warn when "suspicious" code constructs are encountered. While technically legal these usually indicate that an error has been made.
#-Wunused-value: #-Wunused-value:
#-Wunused-parameter: find usused variables with "parameter" attribute
#-Wunderflow: produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation #-Wunderflow: produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation
# #-Wswitch: warn whenever a "switch" statement has an index of enumerated type and lacks a "case" for one or more of the named codes of that
# enumeration. (The presence of a "default" label prevents this warning.) "case" labels outside the enumeration range also provoke
# warnings when this option is used (even if there is a "default" label)
#-Wstrict-overflow
#-Wattributes Warn about inappropriate attribute usage
# -Wunsafe-loop-optimizations Warn if the loop cannot be optimized due to nontrivial assumptions.
################################################################################################### ###################################################################################################
#OPTIONS FOR GFORTRAN 4.6 #OPTIONS FOR GFORTRAN 4.6
#-Wsuggest-attribute=const: #-Wsuggest-attribute=const:
#-Wsuggest-attribute=noreturn: #-Wsuggest-attribute=noreturn:
#-Wsuggest-attribute=pure: #-Wsuggest-attribute=pure:
# #-Wreal-q-constant: Warn about real-literal-constants with 'q' exponent-letter
#MORE OPTIONS FOR DEBUGGING DURING COMPILING #MORE OPTIONS FOR DEBUGGING DURING COMPILING
#-Wline-truncation: too many warnings because we have comments beyond character 132 #-Wline-truncation: too many warnings because we have comments beyond character 132
#-Wintrinsic-std: warnings because of "flush" is not longer in the standard, but still an intrinsic fuction of the compilers: #-Wintrinsic-std: warnings because of "flush" is not longer in the standard, but still an intrinsic fuction of the compilers:

View File

@ -1,19 +1,19 @@
! Copyright 2011 Max-Planck-Institut für Eisenforschung GmbH ! Copyright 2011,2012 Max-Planck-Institut für Eisenforschung GmbH
! !
! This file is part of DAMASK, ! This file is part of DAMASK,
! the Düsseldorf Advanced MAterial Simulation Kit. ! the Düsseldorf Advanced MAterial Simulation Kit.
! !
! DAMASK is free software: you can redistribute it and/or modify ! DAMASK is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by ! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or ! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version. ! (at your option) any later version.
! !
! DAMASK is distributed in the hope that it will be useful, ! DAMASK is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of ! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details. ! GNU General Public License for more details.
! !
! You should have received a copy of the GNU General Public License ! You should have received a copy of the GNU General Public License
! along with DAMASK. If not, see <http://www.gnu.org/licenses/>. ! along with DAMASK. If not, see <http://www.gnu.org/licenses/>.
! !
!############################################################## !##############################################################

View File

@ -42,7 +42,6 @@ parser.add_option('-f','--formula', dest='formulas', action='extend', type='stri
parser.set_defaults(labels= []) parser.set_defaults(labels= [])
parser.set_defaults(formulas= []) parser.set_defaults(formulas= [])
parser.set_defaults(counter= False)
(options,filenames) = parser.parse_args() (options,filenames) = parser.parse_args()

View File

@ -35,18 +35,18 @@ parsing = [ \
['error_stress', r'^error stress = [ +-eE0123456789.]+ \( ([+-eE0123456789.]+)'], ['error_stress', r'^error stress = [ +-eE0123456789.]+ \( ([+-eE0123456789.]+)'],
['crit_divergence', r'^error divergence = ([ +-eE0123456789.]+) \( [+-eE0123456789.]+'], ['crit_divergence', r'^error divergence = ([ +-eE0123456789.]+) \( [+-eE0123456789.]+'],
['crit_stress', r'^error stress = ([ +-eE0123456789.]+) \( [+-eE0123456789.]+'], ['crit_stress', r'^error stress = ([ +-eE0123456789.]+) \( [+-eE0123456789.]+'],
['max(sym(deltaF))', r'^max symmetrix correction of deformation: ([ +-eE0123456789.]+)'], ['max(sym(deltaF))', r'^max symmetrix correction of deformation = ([ +-eE0123456789.]+)'],
['max(skew(deltaF))', r'^max skew correction of deformation: ([ +-eE0123456789.]+)'], ['max(skew(deltaF))', r'^max skew correction of deformation = ([ +-eE0123456789.]+)'],
['max(sym/skew(avg(deltaF)))', r'^max sym/skew of avg correction: ([ +-eE0123456789.]+)'], ['max(sym/skew(avg(deltaF)))', r'^max sym/skew of avg correction = ([ +-eE0123456789.]+)'],
['det(Fbar)', r'^determinant of new deformation: ([ +-eE0123456789.]+)'], ['det(Fbar)', r'^determinant of new deformation = ([ +-eE0123456789.]+)'],
['max(det(F))', r'^max determinant of deformation:([ +-eE0123456789.]+)'], ['max(det(F))', r'^max determinant of deformation = ([ +-eE0123456789.]+)'],
['min(det(F))', r'^min determinant of deformation:([ +-eE0123456789.]+)'], ['min(det(F))', r'^min determinant of deformation = ([ +-eE0123456789.]+)'],
['div_FT_max', r'^error divergence FT max = ([ +-eE0123456789.]+)'], ['div_FT_max', r'^error divergence FT max = ([ +-eE0123456789.]+)'],
['div_Real_RMS', r'^error divergence Real RMS = ([ +-eE0123456789.]+)'], ['div_Real_RMS', r'^error divergence Real RMS = ([ +-eE0123456789.]+)'],
['div_Real_max', r'^error divergence Real max = ([ +-eE0123456789.]+)'], ['div_Real_max', r'^error divergence Real max = ([ +-eE0123456789.]+)'],
['real(error_FT)', r'^max FT relative error ([ +-eE0123456789.]+) [ +-eE0123456789.]+'], ['real(error_FT)', r'^max FT relative error = ([ +-eE0123456789.]+) [ +-eE0123456789.]+'],
['img(error_FT)', r'^max FT relative error [ +-eE0123456789.]+ ([ +-eE0123456789.]+)'], ['img(error_FT)', r'^max FT relative error = [ +-eE0123456789.]+ ([ +-eE0123456789.]+)'],
['real(error_iFT)', r'^max iFT relative error ([ +-eE0123456789.]+)'], ['real(error_iFT)', r'^max iFT relative error = ([ +-eE0123456789.]+)'],
['error_postProc', r'^max deviat. from postProc =([ +-eE0123456789.]+)'], ['error_postProc', r'^max deviat. from postProc =([ +-eE0123456789.]+)'],
['loadcase', r'^Loadcase (\d+) Increment \d+/\d+ @ Iteration \d+/\d+'] ['loadcase', r'^Loadcase (\d+) Increment \d+/\d+ @ Iteration \d+/\d+']
] ]

View File

@ -1,205 +1,205 @@
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
struct struct
{ {
float phi1, Phi, phi2; float phi1, Phi, phi2;
float ci, iq, fit, avgIQ; float ci, iq, fit, avgIQ;
int phase, ds; int phase, ds;
} data[3000][3000]; } data[3000][3000];
int round2( double x ) int round2( double x )
{ {
double fl, ce; double fl, ce;
fl = floor( x ); fl = floor( x );
ce = ceil( x ); ce = ceil( x );
if( fabs( fl-x ) < fabs( ce-x ) ) if( fabs( fl-x ) < fabs( ce-x ) )
return fl; return fl;
else else
return ce; return ce;
} }
char lineBuffer[200]; char lineBuffer[200];
int ReadFileInfo(FILE *oimStream, int *xmax, int *ymax, double *stepSize ) int ReadFileInfo(FILE *oimStream, int *xmax, int *ymax, double *stepSize )
{ {
double x, y, dxmax; double x, y, dxmax;
long count; long count;
*stepSize = 0; *stepSize = 0;
dxmax = 0; dxmax = 0;
*xmax = 0; *xmax = 0;
while( fgets( lineBuffer, 200, oimStream ) != NULL ) while( fgets( lineBuffer, 200, oimStream ) != NULL )
{ {
if( lineBuffer[0] == '#' ) if( lineBuffer[0] == '#' )
{ {
if( strcmp( lineBuffer, "# GRID: SqrGrid" ) == 0 ) if( strcmp( lineBuffer, "# GRID: SqrGrid" ) == 0 )
{ {
printf("\nThe file is already a square grid file.\nProgram terminated."); printf("\nThe file is already a square grid file.\nProgram terminated.");
return 0; return 0;
} }
count = 0; count = 0;
continue; continue;
} }
if( sscanf( lineBuffer, "%*lf %*lf %*lf %lf %lf %*lf %*lf %*i %*i %*lf %*lf", &x, &y ) != 2 ) if( sscanf( lineBuffer, "%*lf %*lf %*lf %lf %lf %*lf %*lf %*i %*i %*lf %*lf", &x, &y ) != 2 )
return 0; return 0;
if( *stepSize == 0 && x != 0 ) if( *stepSize == 0 && x != 0 )
*stepSize = x; *stepSize = x;
if( x > dxmax ) if( x > dxmax )
{ {
dxmax = x; dxmax = x;
(*xmax)++; (*xmax)++;
} }
count++; count++;
} }
(*xmax)++; (*xmax)++;
*ymax = (int)(count / *xmax ); *ymax = (int)(count / *xmax );
return 1; return 1;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int xx, yy, zz, xlimit, ylimit, zlimit, xlimitOut, xOut; int xx, yy, zz, xlimit, ylimit, zlimit, xlimitOut, xOut;
double stepSize; double stepSize;
char zFilename[50], zOutFilename[50], filename[50]; char zFilename[50], zOutFilename[50], filename[50];
FILE *inStream, *outStream; FILE *inStream, *outStream;
int zStartNumber, zEndNumber; int zStartNumber, zEndNumber;
printf( "\nFilenames must have the format ""root_xxx.ang""" printf( "\nFilenames must have the format ""root_xxx.ang"""
"\nwith xxx indicating a 3-digit integer" "\nwith xxx indicating a 3-digit integer"
"\nEnter oim map filename-root, the start integer and the end integer number of the files: " ); "\nEnter oim map filename-root, the start integer and the end integer number of the files: " );
scanf( "%s %i %i", filename, &zStartNumber, &zEndNumber ); scanf( "%s %i %i", filename, &zStartNumber, &zEndNumber );
zlimit = zEndNumber-zStartNumber+1; zlimit = zEndNumber-zStartNumber+1;
//read the first data file and get all necessary start data //read the first data file and get all necessary start data
sprintf( zFilename, "%s_%03i.ang", filename, zStartNumber ); sprintf( zFilename, "%s_%03i.ang", filename, zStartNumber );
if( (inStream = fopen( zFilename, "r" )) == NULL ) if( (inStream = fopen( zFilename, "r" )) == NULL )
{ {
printf( "\nCan't open %s", zFilename ); printf( "\nCan't open %s", zFilename );
exit( 1 ); exit( 1 );
} }
if( ReadFileInfo( inStream, &xlimit, &ylimit, &stepSize ) == 0 ) if( ReadFileInfo( inStream, &xlimit, &ylimit, &stepSize ) == 0 )
{ {
printf( "\nWrong file format in %s", filename ); printf( "\nWrong file format in %s", filename );
exit( 1 ); exit( 1 );
} }
fclose( inStream ); fclose( inStream );
for( zz=0; zz<zlimit; zz++ ) for( zz=0; zz<zlimit; zz++ )
{ {
printf("\nReading"); printf("\nReading");
sprintf( zFilename, "%s_%03i.ang", filename, zz+zStartNumber ); sprintf( zFilename, "%s_%03i.ang", filename, zz+zStartNumber );
sprintf( zOutFilename, "%s_cub_%03i.ang", filename, zz+zStartNumber ); sprintf( zOutFilename, "%s_cub_%03i.ang", filename, zz+zStartNumber );
if( (inStream = fopen( zFilename, "r" )) != NULL ) if( (inStream = fopen( zFilename, "r" )) != NULL )
{ {
outStream = fopen( zOutFilename, "w" ); outStream = fopen( zOutFilename, "w" );
//read file header //read file header
do do
{ {
if( fscanf( inStream, "%[^\n]\n", lineBuffer ) == EOF ) if( fscanf( inStream, "%[^\n]\n", lineBuffer ) == EOF )
{ {
printf( "\nEarly end of file encountered in ANG file" ); printf( "\nEarly end of file encountered in ANG file" );
exit(1); exit(1);
} }
//write the file header //write the file header
if( lineBuffer[0] == '#' ) if( lineBuffer[0] == '#' )
{ {
if( strcmp( lineBuffer, "# GRID: HexGrid" ) == 0 ) if( strcmp( lineBuffer, "# GRID: HexGrid" ) == 0 )
fprintf( outStream, "# GRID: SqrGrid\n" ); fprintf( outStream, "# GRID: SqrGrid\n" );
else else
fprintf( outStream, "%s\n", lineBuffer ); fprintf( outStream, "%s\n", lineBuffer );
} }
} }
while( lineBuffer[0] == '#' ); while( lineBuffer[0] == '#' );
for( yy=0; yy<ylimit; yy++) for( yy=0; yy<ylimit; yy++)
{ {
printf("."); printf(".");
for( xx=0; xx<xlimit; xx++) for( xx=0; xx<xlimit; xx++)
{ {
//t1: pattern quality, iq: confidence index, avgIQ: average Image Quality //t1: pattern quality, iq: confidence index, avgIQ: average Image Quality
if( sscanf( lineBuffer, "%f %f %f %*f %*f %f %f %i %i %f %f", if( sscanf( lineBuffer, "%f %f %f %*f %*f %f %f %i %i %f %f",
&data[xx][yy].phi1, &data[xx][yy].phi1,
&data[xx][yy].Phi, &data[xx][yy].Phi,
&data[xx][yy].phi2, &data[xx][yy].phi2,
&data[xx][yy].iq, &data[xx][yy].iq,
&data[xx][yy].ci, &data[xx][yy].ci,
&data[xx][yy].phase, &data[xx][yy].phase,
&data[xx][yy].ds, &data[xx][yy].ds,
&data[xx][yy].fit, &data[xx][yy].fit,
&data[xx][yy].avgIQ ) != 9 ) &data[xx][yy].avgIQ ) != 9 )
{ {
printf( "\nWrong file format in %s", filename ); printf( "\nWrong file format in %s", filename );
exit( 1 ); exit( 1 );
} }
//read the next line buffer if there is any. //read the next line buffer if there is any.
//ylimit%2 only for hexagonal grid data (odd lines are shorter by 1 pixel) //ylimit%2 only for hexagonal grid data (odd lines are shorter by 1 pixel)
if( yy%2 == 1 && xx == xlimit-1 ) if( yy%2 == 1 && xx == xlimit-1 )
{ {
data[xx][yy].phi1 = data[xx-1][yy].phi1; data[xx][yy].phi1 = data[xx-1][yy].phi1;
data[xx][yy].Phi = data[xx-1][yy].Phi; data[xx][yy].Phi = data[xx-1][yy].Phi;
data[xx][yy].phi2 = data[xx-1][yy].phi2; data[xx][yy].phi2 = data[xx-1][yy].phi2;
data[xx][yy].iq = data[xx-1][yy].iq; data[xx][yy].iq = data[xx-1][yy].iq;
data[xx][yy].ci = data[xx-1][yy].ci; data[xx][yy].ci = data[xx-1][yy].ci;
data[xx][yy].phase = data[xx-1][yy].phase; data[xx][yy].phase = data[xx-1][yy].phase;
data[xx][yy].ds = data[xx-1][yy].ds; data[xx][yy].ds = data[xx-1][yy].ds;
data[xx][yy].fit = data[xx-1][yy].fit; data[xx][yy].fit = data[xx-1][yy].fit;
data[xx][yy].avgIQ = data[xx-1][yy].avgIQ; data[xx][yy].avgIQ = data[xx-1][yy].avgIQ;
} }
else else
{ {
if( fscanf( inStream, "%[^\n]\n", lineBuffer ) == EOF ) if( fscanf( inStream, "%[^\n]\n", lineBuffer ) == EOF )
{ {
printf( "\nEarly end of file encountered in ANG file" ); printf( "\nEarly end of file encountered in ANG file" );
exit(1); exit(1);
} }
} }
}//end for(x... }//end for(x...
}//end for(y... }//end for(y...
fclose( inStream ); fclose( inStream );
printf("\nWriting"); printf("\nWriting");
//the step size in y-direction (=0.866*stepSizeX) //the step size in y-direction (=0.866*stepSizeX)
//is the new step size for x and y //is the new step size for x and y
xlimitOut = round2( (double)xlimit/0.866); xlimitOut = round2( (double)xlimit/0.866);
for( yy=0; yy<ylimit; yy++) for( yy=0; yy<ylimit; yy++)
{ {
printf("."); printf(".");
for( xx=0; xx<xlimitOut; xx++) for( xx=0; xx<xlimitOut; xx++)
{ {
xOut = round2( (double)xx * 0.866 ); xOut = round2( (double)xx * 0.866 );
fprintf( outStream, "%f %f %f %f %f %f %f %i %i %f %f\n", fprintf( outStream, "%f %f %f %f %f %f %f %i %i %f %f\n",
data[xOut][yy].phi1, data[xOut][yy].phi1,
data[xOut][yy].Phi, data[xOut][yy].Phi,
data[xOut][yy].phi2, data[xOut][yy].phi2,
xx * stepSize * 0.866, xx * stepSize * 0.866,
yy * stepSize * 0.866, yy * stepSize * 0.866,
data[xOut][yy].iq, data[xOut][yy].iq,
data[xOut][yy].ci, data[xOut][yy].ci,
data[xOut][yy].phase, data[xOut][yy].phase,
data[xOut][yy].ds, data[xOut][yy].ds,
data[xOut][yy].fit, data[xOut][yy].fit,
data[xOut][yy].avgIQ ); data[xOut][yy].avgIQ );
}//end for( xx... }//end for( xx...
}//end for( yy... }//end for( yy...
fclose( outStream ); fclose( outStream );
} }
else else
{ {
printf( "\nExpected file %s does not exist", zFilename ); printf( "\nExpected file %s does not exist", zFilename );
exit( 1 ); exit( 1 );
} }
} }
return 0; return 0;
} }

View File

@ -1,93 +1,93 @@
!prec.f90 407 2009-08-31 15:09:15Z MPIE\f.roters !prec.f90 407 2009-08-31 15:09:15Z MPIE\f.roters
!############################################################## !##############################################################
MODULE prec MODULE prec
!############################################################## !##############################################################
implicit none implicit none
! *** Precision of real and integer variables *** ! *** Precision of real and integer variables ***
integer, parameter :: pReal = selected_real_kind(15,300) ! 15 significant digits, up to 1e+-300 integer, parameter :: pReal = selected_real_kind(15,300) ! 15 significant digits, up to 1e+-300
integer, parameter :: pInt = selected_int_kind(9) ! up to +- 1e9 integer, parameter :: pInt = selected_int_kind(9) ! up to +- 1e9
integer, parameter :: pLongInt = 8 ! should be 64bit integer, parameter :: pLongInt = 8 ! should be 64bit
END MODULE prec END MODULE prec
program voronoi program voronoi
use prec, only: pReal, pInt use prec, only: pReal, pInt
implicit none implicit none
logical, dimension(:), allocatable :: seedmap logical, dimension(:), allocatable :: seedmap
character(len=1024) filename character(len=1024) filename
integer(pInt), dimension(3) :: seedcoord integer(pInt), dimension(3) :: seedcoord
integer(pInt), dimension(:), allocatable :: rndInit integer(pInt), dimension(:), allocatable :: rndInit
integer(pInt) a, b, c, N_Seeds, seedpoint, i, randomSeed, rndSize integer(pInt) a, b, c, N_Seeds, seedpoint, i, randomSeed, rndSize
real(pReal), dimension(:,:), allocatable :: grainEuler, seeds real(pReal), dimension(:,:), allocatable :: grainEuler, seeds
real(pReal), parameter :: pi = 3.14159265358979323846264338327950288419716939937510_pReal real(pReal), parameter :: pi = 3.14159265358979323846264338327950288419716939937510_pReal
print*, '******************************************************************************' print*, '******************************************************************************'
print*, ' Voronoi description file' print*, ' Voronoi description file'
print*, '******************************************************************************' print*, '******************************************************************************'
print*, '$Id$' print*, '$Id$'
print*, '' print*, ''
print*, 'generates:' print*, 'generates:'
print*, ' * description file "_OUTPUT_.seeds":' print*, ' * description file "_OUTPUT_.seeds":'
print*, '' print*, ''
write(*, '(A)', advance = 'NO') 'output seed filename: ' write(*, '(A)', advance = 'NO') 'output seed filename: '
read(*, *), filename read(*, *), filename
write(*, '(A)', advance = 'NO') 'seed of random number generator: ' write(*, '(A)', advance = 'NO') 'seed of random number generator: '
read(*, *), randomSeed; randomSeed = max(0_pInt,randomSeed) read(*, *), randomSeed; randomSeed = max(0_pInt,randomSeed)
write(*, '(A)', advance = 'NO') 'number of grains: ' write(*, '(A)', advance = 'NO') 'number of grains: '
read(*, *), N_Seeds read(*, *), N_Seeds
write(*, '(A)', advance = 'NO') 'min. Fourier points in x: ' write(*, '(A)', advance = 'NO') 'min. Fourier points in x: '
read(*, *), a read(*, *), a
write(*, '(A)', advance = 'NO') 'min. Fourier points in y: ' write(*, '(A)', advance = 'NO') 'min. Fourier points in y: '
read(*, *), b read(*, *), b
write(*, '(A)', advance = 'NO') 'min. Fourier points in z: ' write(*, '(A)', advance = 'NO') 'min. Fourier points in z: '
read(*, *), c read(*, *), c
allocate (seedmap(a*b*c)); seedmap = .false. ! logical to store information which position is occupied by a voronoi seed allocate (seedmap(a*b*c)); seedmap = .false. ! logical to store information which position is occupied by a voronoi seed
allocate (seeds(N_Seeds,3)) allocate (seeds(N_Seeds,3))
allocate (grainEuler(N_Seeds,3)) allocate (grainEuler(N_Seeds,3))
call random_seed(size=rndSize) call random_seed(size=rndSize)
allocate(rndInit(rndSize)) allocate(rndInit(rndSize))
rndInit = randomSeed rndInit = randomSeed
call random_seed(put=rndInit) call random_seed(put=rndInit)
call random_seed(get=rndInit) call random_seed(get=rndInit)
do i=1, N_Seeds do i=1, N_Seeds
call random_number(grainEuler(i,1)) call random_number(grainEuler(i,1))
call random_number(grainEuler(i,2)) call random_number(grainEuler(i,2))
call random_number(grainEuler(i,3)) call random_number(grainEuler(i,3))
grainEuler(i,1) = (grainEuler(i,1))*360.0 grainEuler(i,1) = (grainEuler(i,1))*360.0
grainEuler(i,2) = acos(2.0_pReal*(grainEuler(i,2))-1.0_pReal)*180.0/pi grainEuler(i,2) = acos(2.0_pReal*(grainEuler(i,2))-1.0_pReal)*180.0/pi
grainEuler(i,3) = grainEuler(i,3)*360.0 grainEuler(i,3) = grainEuler(i,3)*360.0
enddo enddo
!generate random position of seeds for voronoi tessellation !generate random position of seeds for voronoi tessellation
i = 1 i = 1
do while (i <= N_Seeds) do while (i <= N_Seeds)
call random_number(seeds(i,1)); seedcoord(1) = min(a,int(seeds(i,1)*a)+1_pInt)-1_pInt call random_number(seeds(i,1)); seedcoord(1) = min(a,int(seeds(i,1)*a)+1_pInt)-1_pInt
call random_number(seeds(i,2)); seedcoord(2) = min(b,int(seeds(i,2)*b)+1_pInt)-1_pInt call random_number(seeds(i,2)); seedcoord(2) = min(b,int(seeds(i,2)*b)+1_pInt)-1_pInt
call random_number(seeds(i,3)); seedcoord(3) = min(c,int(seeds(i,3)*c)+1_pInt)-1_pInt call random_number(seeds(i,3)); seedcoord(3) = min(c,int(seeds(i,3)*c)+1_pInt)-1_pInt
seedpoint = seedcoord(1) + seedcoord(2)*a + seedcoord(3)*a*b seedpoint = seedcoord(1) + seedcoord(2)*a + seedcoord(3)*a*b
if (.not. seedmap(seedpoint+1)) then if (.not. seedmap(seedpoint+1)) then
seedmap(seedpoint+1) = .true. seedmap(seedpoint+1) = .true.
i = i + 1 i = i + 1
end if end if
end do end do
! write description file with orientation and position of each seed ! write description file with orientation and position of each seed
open(21, file = trim(filename)//('.seeds')) open(21, file = trim(filename)//('.seeds'))
write(21, '(i1,a1,a6)') 4,achar(9),'header' write(21, '(i1,a1,a6)') 4,achar(9),'header'
write(21, '(A, I8, A, I8, A, I8)') 'resolution a ', a, ' b ', b, ' c ', c write(21, '(A, I8, A, I8, A, I8)') 'resolution a ', a, ' b ', b, ' c ', c
write(21, '(A, I8)') 'grains', N_Seeds write(21, '(A, I8)') 'grains', N_Seeds
write(21, '(A, I8)') 'random seed ',rndInit(1) write(21, '(A, I8)') 'random seed ',rndInit(1)
write(21,'(6(a,a1))') 'x',achar(9),'y',achar(9),'z',achar(9),'phi1',achar(9),'Phi',achar(9),'phi2',achar(9) write(21,'(6(a,a1))') 'x',achar(9),'y',achar(9),'z',achar(9),'phi1',achar(9),'Phi',achar(9),'phi2',achar(9)
do i = 1, n_Seeds do i = 1, n_Seeds
write(21, '(6(F10.6,a1))'),seeds(i,1), achar(9), seeds(i,2), achar(9), seeds(i,3), achar(9), & write(21, '(6(F10.6,a1))'),seeds(i,1), achar(9), seeds(i,2), achar(9), seeds(i,3), achar(9), &
grainEuler(i,1),achar(9), grainEuler(i,2),achar(9), grainEuler(i,3),achar(9) grainEuler(i,1),achar(9), grainEuler(i,2),achar(9), grainEuler(i,3),achar(9)
end do end do
close(21) close(21)
deallocate (rndInit) deallocate (rndInit)
end program voronoi end program voronoi

View File

@ -1,365 +1,365 @@
!prec.f90 407 2009-08-31 15:09:15Z MPIE\f.roters !prec.f90 407 2009-08-31 15:09:15Z MPIE\f.roters
!############################################################## !##############################################################
MODULE prec MODULE prec
!############################################################## !##############################################################
implicit none implicit none
! *** Precision of real and integer variables *** ! *** Precision of real and integer variables ***
integer, parameter :: pReal = selected_real_kind(15,300) ! 15 significant digits, up to 1e+-300 integer, parameter :: pReal = selected_real_kind(15,300) ! 15 significant digits, up to 1e+-300
integer, parameter :: pInt = selected_int_kind(9) ! up to +- 1e9 integer, parameter :: pInt = selected_int_kind(9) ! up to +- 1e9
integer, parameter :: pLongInt = 8 ! should be 64bit integer, parameter :: pLongInt = 8 ! should be 64bit
END MODULE prec END MODULE prec
!IO.f90 693 2010-11-04 18:18:01Z MPIE\c.kords !IO.f90 693 2010-11-04 18:18:01Z MPIE\c.kords
!############################################################## !##############################################################
MODULE IO MODULE IO
!############################################################## !##############################################################
CONTAINS CONTAINS
!******************************************************************** !********************************************************************
! identifies lines without content ! identifies lines without content
!******************************************************************** !********************************************************************
pure function IO_isBlank (line) pure function IO_isBlank (line)
use prec, only: pInt use prec, only: pInt
implicit none implicit none
character(len=*), intent(in) :: line character(len=*), intent(in) :: line
character(len=*), parameter :: blank = achar(32)//achar(9)//achar(10)//achar(13) ! whitespaces character(len=*), parameter :: blank = achar(32)//achar(9)//achar(10)//achar(13) ! whitespaces
character(len=*), parameter :: comment = achar(35) ! comment id '#' character(len=*), parameter :: comment = achar(35) ! comment id '#'
integer(pInt) posNonBlank, posComment integer(pInt) posNonBlank, posComment
logical IO_isBlank logical IO_isBlank
posNonBlank = verify(line,blank) posNonBlank = verify(line,blank)
posComment = scan(line,comment) posComment = scan(line,comment)
IO_isBlank = posNonBlank == 0 .or. posNonBlank == posComment IO_isBlank = posNonBlank == 0 .or. posNonBlank == posComment
return return
endfunction endfunction
!******************************************************************** !********************************************************************
! read string value at pos from line ! read string value at pos from line
!******************************************************************** !********************************************************************
pure function IO_stringValue (line,positions,pos) pure function IO_stringValue (line,positions,pos)
use prec, only: pReal,pInt use prec, only: pReal,pInt
implicit none implicit none
character(len=*), intent(in) :: line character(len=*), intent(in) :: line
integer(pInt), intent(in) :: positions(*),pos integer(pInt), intent(in) :: positions(*),pos
character(len=1+positions(pos*2+1)-positions(pos*2)) IO_stringValue character(len=1+positions(pos*2+1)-positions(pos*2)) IO_stringValue
if (positions(1) < pos) then if (positions(1) < pos) then
IO_stringValue = '' IO_stringValue = ''
else else
IO_stringValue = line(positions(pos*2):positions(pos*2+1)) IO_stringValue = line(positions(pos*2):positions(pos*2+1))
endif endif
return return
endfunction endfunction
!******************************************************************** !********************************************************************
! read float value at pos from line ! read float value at pos from line
!******************************************************************** !********************************************************************
pure function IO_floatValue (line,positions,pos) pure function IO_floatValue (line,positions,pos)
use prec, only: pReal,pInt use prec, only: pReal,pInt
implicit none implicit none
character(len=*), intent(in) :: line character(len=*), intent(in) :: line
integer(pInt), intent(in) :: positions(*),pos integer(pInt), intent(in) :: positions(*),pos
real(pReal) IO_floatValue real(pReal) IO_floatValue
if (positions(1) < pos) then if (positions(1) < pos) then
IO_floatValue = 0.0_pReal IO_floatValue = 0.0_pReal
else else
read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_floatValue read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_floatValue
endif endif
return return
100 IO_floatValue = huge(1.0_pReal) 100 IO_floatValue = huge(1.0_pReal)
return return
endfunction endfunction
!******************************************************************** !********************************************************************
! read int value at pos from line ! read int value at pos from line
!******************************************************************** !********************************************************************
pure function IO_intValue (line,positions,pos) pure function IO_intValue (line,positions,pos)
use prec, only: pReal,pInt use prec, only: pReal,pInt
implicit none implicit none
character(len=*), intent(in) :: line character(len=*), intent(in) :: line
integer(pInt), intent(in) :: positions(*),pos integer(pInt), intent(in) :: positions(*),pos
integer(pInt) IO_intValue integer(pInt) IO_intValue
if (positions(1) < pos) then if (positions(1) < pos) then
IO_intValue = 0_pInt IO_intValue = 0_pInt
else else
read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_intValue read(UNIT=line(positions(pos*2):positions(pos*2+1)),ERR=100,FMT=*) IO_intValue
endif endif
return return
100 IO_intValue = huge(1_pInt) 100 IO_intValue = huge(1_pInt)
return return
endfunction endfunction
!******************************************************************** !********************************************************************
! change character in line to lower case ! change character in line to lower case
!******************************************************************** !********************************************************************
pure function IO_lc (line) pure function IO_lc (line)
use prec, only: pInt use prec, only: pInt
implicit none implicit none
character (len=*), intent(in) :: line character (len=*), intent(in) :: line
character (len=len(line)) IO_lc character (len=len(line)) IO_lc
integer(pInt) i integer(pInt) i
IO_lc = line IO_lc = line
do i=1,len(line) do i=1,len(line)
if(64<iachar(line(i:i)) .and. iachar(line(i:i))<91) IO_lc(i:i)=achar(iachar(line(i:i))+32) if(64<iachar(line(i:i)) .and. iachar(line(i:i))<91) IO_lc(i:i)=achar(iachar(line(i:i))+32)
enddo enddo
return return
endfunction endfunction
!******************************************************************** !********************************************************************
! locate at most N space-separated parts in line ! locate at most N space-separated parts in line
! return array containing number of parts in line and ! return array containing number of parts in line and
! the left/right positions of at most N to be used by IO_xxxVal ! the left/right positions of at most N to be used by IO_xxxVal
!******************************************************************** !********************************************************************
! pure function IO_stringPos (line,N) ! pure function IO_stringPos (line,N)
function IO_stringPos (line,N) function IO_stringPos (line,N)
use prec, only: pReal,pInt use prec, only: pReal,pInt
implicit none implicit none
character(len=*), intent(in) :: line character(len=*), intent(in) :: line
character(len=*), parameter :: sep=achar(44)//achar(32)//achar(9)//achar(10)//achar(13) ! comma and whitespaces character(len=*), parameter :: sep=achar(44)//achar(32)//achar(9)//achar(10)//achar(13) ! comma and whitespaces
integer(pInt), intent(in) :: N integer(pInt), intent(in) :: N
integer(pInt) left,right integer(pInt) left,right
integer(pInt) IO_stringPos(1+N*2) integer(pInt) IO_stringPos(1+N*2)
IO_stringPos = -1 IO_stringPos = -1
IO_stringPos(1) = 0 IO_stringPos(1) = 0
right = 0 right = 0
do while (verify(line(right+1:),sep)>0) do while (verify(line(right+1:),sep)>0)
left = right + verify(line(right+1:),sep) left = right + verify(line(right+1:),sep)
right = left + scan(line(left:),sep) - 2 right = left + scan(line(left:),sep) - 2
if ( IO_stringPos(1)<N ) then if ( IO_stringPos(1)<N ) then
IO_stringPos(1+IO_stringPos(1)*2+1) = left IO_stringPos(1+IO_stringPos(1)*2+1) = left
IO_stringPos(1+IO_stringPos(1)*2+2) = right IO_stringPos(1+IO_stringPos(1)*2+2) = right
endif endif
IO_stringPos(1) = IO_stringPos(1)+1 IO_stringPos(1) = IO_stringPos(1)+1
enddo enddo
return return
endfunction endfunction
END MODULE END MODULE
program voronoi program voronoi
use prec, only: pReal, pInt use prec, only: pReal, pInt
use IO use IO
implicit none implicit none
logical :: gotN_Seeds=.false., gotResolution = .false. logical :: gotN_Seeds=.false., gotResolution = .false.
logical, dimension(:), allocatable :: grainCheck logical, dimension(:), allocatable :: grainCheck
character(len=1024) input_name, output_name, format1, format2, N_Digits, line, key character(len=1024) input_name, output_name, format1, format2, N_Digits, line, key
integer(pInt) N_Seeds, theGrain, i, j, k, l, m integer(pInt) N_Seeds, theGrain, i, j, k, l, m
integer(pInt), dimension (1+2*7) :: posGeom integer(pInt), dimension (1+2*7) :: posGeom
real(pReal), dimension(:,:), allocatable :: grainEuler, seeds real(pReal), dimension(:,:), allocatable :: grainEuler, seeds
real(pReal), dimension(3) :: step,geomdim,delta real(pReal), dimension(3) :: step,geomdim,delta
integer(pInt), dimension(3) :: resolution integer(pInt), dimension(3) :: resolution
logical, dimension(3) :: validDim logical, dimension(3) :: validDim
real(pReal) minDist, theDist real(pReal) minDist, theDist
real(pReal), parameter :: pi = 3.14159265358979323846264338327950288419716939937510_pReal real(pReal), parameter :: pi = 3.14159265358979323846264338327950288419716939937510_pReal
print*, '******************************************************************************' print*, '******************************************************************************'
print*, ' Spectral Method Problem Set-up' print*, ' Spectral Method Problem Set-up'
print*, '******************************************************************************' print*, '******************************************************************************'
print*, '$Id$' print*, '$Id$'
print*, '' print*, ''
print*, 'generates:' print*, 'generates:'
print*, ' * geom file "_OUTPUT_.geom": Geometrical information for solver' print*, ' * geom file "_OUTPUT_.geom": Geometrical information for solver'
print*, ' * material file "material.config": Orientation information for solver' print*, ' * material file "material.config": Orientation information for solver'
print*, ' * "_OUTPUT_.spectral": combined information for solver' print*, ' * "_OUTPUT_.spectral": combined information for solver'
print*, '' print*, ''
write(*, '(A)', advance = 'NO') 'output filename: ' write(*, '(A)', advance = 'NO') 'output filename: '
read(*, *), output_name read(*, *), output_name
write(*, '(A)', advance = 'NO') 'seed input filename (w/o extension .seeds): ' write(*, '(A)', advance = 'NO') 'seed input filename (w/o extension .seeds): '
read(*, *), input_name read(*, *), input_name
open(20, file = trim(input_name)//('.seeds'), status='old', action='read') open(20, file = trim(input_name)//('.seeds'), status='old', action='read')
rewind(20) rewind(20)
do do
read(20,'(a1024)',END = 100) line read(20,'(a1024)',END = 100) line
if (IO_isBlank(line)) cycle ! skip empty lines if (IO_isBlank(line)) cycle ! skip empty lines
posGeom = IO_stringPos(line,7) posGeom = IO_stringPos(line,7)
select case ( IO_lc(IO_StringValue(line,posGeom,1)) ) select case ( IO_lc(IO_StringValue(line,posGeom,1)) )
case ('grains') case ('grains')
gotN_Seeds = .true. gotN_Seeds = .true.
N_Seeds = IO_intValue(line,posGeom,2) N_Seeds = IO_intValue(line,posGeom,2)
case ('resolution') case ('resolution')
gotResolution = .true. gotResolution = .true.
do i = 2,6,2 do i = 2,6,2
select case (IO_lc(IO_stringValue(line,posGeom,i))) select case (IO_lc(IO_stringValue(line,posGeom,i)))
case('a') case('a')
resolution(1) = IO_intValue(line,posGeom,i+1) resolution(1) = IO_intValue(line,posGeom,i+1)
case('b') case('b')
resolution(2) = IO_intValue(line,posGeom,i+1) resolution(2) = IO_intValue(line,posGeom,i+1)
case('c') case('c')
resolution(3) = IO_intValue(line,posGeom,i+1) resolution(3) = IO_intValue(line,posGeom,i+1)
end select end select
enddo enddo
end select end select
if (gotN_Seeds .and. gotResolution) exit if (gotN_Seeds .and. gotResolution) exit
enddo enddo
100 allocate(grainEuler(N_Seeds,3)) 100 allocate(grainEuler(N_Seeds,3))
allocate(seeds(N_Seeds,3)) allocate(seeds(N_Seeds,3))
allocate(grainCheck(N_Seeds)) allocate(grainCheck(N_Seeds))
grainCheck = .false. grainCheck = .false.
print*, 'resolution: ' ,resolution(1),resolution(2),resolution(3) print*, 'resolution: ' ,resolution(1),resolution(2),resolution(3)
write(*, '(A)', advance = 'NO') 'resolution in x: ' write(*, '(A)', advance = 'NO') 'resolution in x: '
read(*, *), resolution(1) read(*, *), resolution(1)
write(*, '(A)', advance = 'NO') 'resolution in y: ' write(*, '(A)', advance = 'NO') 'resolution in y: '
read(*, *), resolution(2) read(*, *), resolution(2)
write(*, '(A)', advance = 'NO') 'resolution in z: ' write(*, '(A)', advance = 'NO') 'resolution in z: '
read(*, *), resolution(3) read(*, *), resolution(3)
step(1) = 1.0_pReal/real(resolution(1),pReal) step(1) = 1.0_pReal/real(resolution(1),pReal)
step(2) = 1.0_pReal/real(resolution(2),pReal) step(2) = 1.0_pReal/real(resolution(2),pReal)
step(3) = 1.0_pReal/real(resolution(3),pReal) step(3) = 1.0_pReal/real(resolution(3),pReal)
write(*, '(A)', advance = 'NO') 'size in x: ' write(*, '(A)', advance = 'NO') 'size in x: '
read(*, *), geomdim(1) read(*, *), geomdim(1)
write(*, '(A)', advance = 'NO') 'size in y: ' write(*, '(A)', advance = 'NO') 'size in y: '
read(*, *), geomdim(2) read(*, *), geomdim(2)
write(*, '(A)', advance = 'NO') 'size in z: ' write(*, '(A)', advance = 'NO') 'size in z: '
read(*, *), geomdim(3) read(*, *), geomdim(3)
rewind(20) rewind(20)
read(20,'(a1024)') line read(20,'(a1024)') line
posGeom = IO_stringPos(line,2) posGeom = IO_stringPos(line,2)
key = IO_stringValue(line,posGeom,2) key = IO_stringValue(line,posGeom,2)
if (IO_lc(key(1:4)) == 'head') then if (IO_lc(key(1:4)) == 'head') then
do i=1,IO_intValue(line,posGeom,1); read(20,'(a1024)') line; enddo do i=1,IO_intValue(line,posGeom,1); read(20,'(a1024)') line; enddo
else else
rewind(20) rewind(20)
endif endif
do i=1, N_seeds do i=1, N_seeds
read(20,'(a1024)') line read(20,'(a1024)') line
if (IO_isBlank(line)) cycle ! skip empty lines if (IO_isBlank(line)) cycle ! skip empty lines
posGeom = IO_stringPos(line,6) ! split line posGeom = IO_stringPos(line,6) ! split line
do j=1,3 do j=1,3
seeds(i,j) = IO_floatValue(line,posGeom,j) seeds(i,j) = IO_floatValue(line,posGeom,j)
grainEuler(i,j) = IO_floatValue(line,posGeom,j+3) grainEuler(i,j) = IO_floatValue(line,posGeom,j+3)
enddo enddo
enddo enddo
close(20) close(20)
!check dimensions, set dimension with 0 to smallest step of other dimensions !check dimensions, set dimension with 0 to smallest step of other dimensions
validDim = .false. validDim = .false.
do i = 1,3 do i = 1,3
if(geomdim(i) .gt. 0.0) validDim(i) = .true. if(geomdim(i) .gt. 0.0) validDim(i) = .true.
enddo enddo
if(all(validDim .eqv. .false.)) then if(all(validDim .eqv. .false.)) then
geomdim(maxval(maxloc(resolution))) = 1.0 geomdim(maxval(maxloc(resolution))) = 1.0
validDim(maxval(maxloc(resolution))) = .true. validDim(maxval(maxloc(resolution))) = .true.
print*, 'no valid dimension specified, using automated setting' print*, 'no valid dimension specified, using automated setting'
endif endif
do i=1,3 do i=1,3
if (validDim(i) .eqv. .false.) then if (validDim(i) .eqv. .false.) then
print*, 'rescaling ivalid dimension' , i print*, 'rescaling ivalid dimension' , i
geomdim(i) = maxval(geomdim/real(resolution),validDim)*real(resolution(i)) geomdim(i) = maxval(geomdim/real(resolution),validDim)*real(resolution(i))
endif endif
enddo enddo
! calculate No. of digits needed for name of the grains ! calculate No. of digits needed for name of the grains
i = 1 + int( log10(real( N_Seeds ))) i = 1 + int( log10(real( N_Seeds )))
write(N_Digits, *) i write(N_Digits, *) i
N_Digits = adjustl( N_Digits ) N_Digits = adjustl( N_Digits )
!write material.config header and add a microstructure entry for every grain !write material.config header and add a microstructure entry for every grain
open(20, file = trim(output_name)//('_material.config')) open(20, file = trim(output_name)//('_material.config'))
write(20, '(A)'), '<microstructure>' write(20, '(A)'), '<microstructure>'
format1 = '(A, I'//trim(N_Digits)//'.'//trim(N_Digits)//', A)' format1 = '(A, I'//trim(N_Digits)//'.'//trim(N_Digits)//', A)'
format2 = '(A, I'//trim(N_Digits)//', A)' format2 = '(A, I'//trim(N_Digits)//', A)'
do i = 1, N_Seeds do i = 1, N_Seeds
write(20, trim(format1)), '[Grain', i, ']' write(20, trim(format1)), '[Grain', i, ']'
write(20, '(A)'), 'crystallite 1' write(20, '(A)'), 'crystallite 1'
write(20, trim(format2)), '(constituent) phase 1 texture ', i, ' fraction 1.0' write(20, trim(format2)), '(constituent) phase 1 texture ', i, ' fraction 1.0'
end do end do
! get random euler angles for every grain, store them in grainEuler and write them to the material.config file ! get random euler angles for every grain, store them in grainEuler and write them to the material.config file
format2 = '(6(A, F10.6))' format2 = '(6(A, F10.6))'
write(20, '(/, A)'), '<texture>' write(20, '(/, A)'), '<texture>'
do i = 1, N_Seeds do i = 1, N_Seeds
write(20, trim(format1)), '[Grain', i, ']' write(20, trim(format1)), '[Grain', i, ']'
write(20, trim(format2)), '(gauss) phi1 ', grainEuler(i,1), ' Phi ', grainEuler(i,2), & write(20, trim(format2)), '(gauss) phi1 ', grainEuler(i,1), ' Phi ', grainEuler(i,2), &
&' Phi2 ', grainEuler(i,3), ' scatter 0.0 fraction 1.0' &' Phi2 ', grainEuler(i,3), ' scatter 0.0 fraction 1.0'
end do end do
close(20) close(20)
print*, 'material.config done.' print*, 'material.config done.'
!write header of geom file !write header of geom file
open(20, file = ((trim(output_name))//'.geom')) open(20, file = ((trim(output_name))//'.geom'))
open(21, file = ((trim(output_name))//'.spectral')) open(21, file = ((trim(output_name))//'.spectral'))
write(20, '(A)'), '3 header' write(20, '(A)'), '3 header'
write(20, '(A, I8, A, I8, A, I8)'), 'resolution a ', resolution(1), ' b ', resolution(2), ' c ', resolution(3) write(20, '(A, I8, A, I8, A, I8)'), 'resolution a ', resolution(1), ' b ', resolution(2), ' c ', resolution(3)
write(20, '(A, g17.10, A, g17.10, A, g17.10)'), 'dimension x ', geomdim(1), ' y ', geomdim(2), ' z ', geomdim(3) write(20, '(A, g17.10, A, g17.10, A, g17.10)'), 'dimension x ', geomdim(1), ' y ', geomdim(2), ' z ', geomdim(3)
write(20, '(A)'), 'homogenization 1' write(20, '(A)'), 'homogenization 1'
format1 = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')' ! geom format format1 = '(I'//trim(N_Digits)//'.'//trim(N_Digits)//')' ! geom format
format2 = '(3(tr2, f6.2), 3(tr2,g10.5), I10, a)' ! spectral (Lebensohn) format format2 = '(3(tr2, f6.2), 3(tr2,g10.5), I10, a)' ! spectral (Lebensohn) format
! perform voronoi tessellation and write result to files ! perform voronoi tessellation and write result to files
do i = 0, resolution(1)*resolution(2)*resolution(3)-1 do i = 0, resolution(1)*resolution(2)*resolution(3)-1
minDist = geomdim(1)*geomdim(1)+geomdim(2)*geomdim(2)+geomdim(3)*geomdim(3) ! diagonal of rve minDist = geomdim(1)*geomdim(1)+geomdim(2)*geomdim(2)+geomdim(3)*geomdim(3) ! diagonal of rve
do j = 1, N_Seeds do j = 1, N_Seeds
delta(1) = step(1)*(mod(i , resolution(1))+0.5_pReal) - seeds(j,1) delta(1) = step(1)*(mod(i , resolution(1))+0.5_pReal) - seeds(j,1)
delta(2) = step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal) - seeds(j,2) delta(2) = step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal) - seeds(j,2)
delta(3) = step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal) - seeds(j,3) delta(3) = step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal) - seeds(j,3)
do k = -1, 1 ! left, me, right image do k = -1, 1 ! left, me, right image
do l = -1, 1 ! front, me, back image do l = -1, 1 ! front, me, back image
do m = -1, 1 ! lower, me, upper image do m = -1, 1 ! lower, me, upper image
theDist = ( geomdim(1) * ( delta(1)-real(k,pReal) ) )**2 + & theDist = ( geomdim(1) * ( delta(1)-real(k,pReal) ) )**2 + &
( geomdim(2) * ( delta(2)-real(l,pReal) ) )**2 + & ( geomdim(2) * ( delta(2)-real(l,pReal) ) )**2 + &
( geomdim(3) * ( delta(3)-real(m,pReal) ) )**2 ( geomdim(3) * ( delta(3)-real(m,pReal) ) )**2
if (theDist < minDist) then if (theDist < minDist) then
minDist = theDist minDist = theDist
theGrain = j theGrain = j
endif endif
enddo enddo
enddo enddo
enddo enddo
enddo enddo
grainCheck(theGrain) = .true. grainCheck(theGrain) = .true.
write(20, trim(format1)), theGrain write(20, trim(format1)), theGrain
write(21, trim(format2)), grainEuler(theGrain,1), grainEuler(theGrain,2), grainEuler(theGrain,3), & write(21, trim(format2)), grainEuler(theGrain,1), grainEuler(theGrain,2), grainEuler(theGrain,3), &
geomdim(1)*step(1)*(mod(i , resolution(1))+0.5_pReal), & geomdim(1)*step(1)*(mod(i , resolution(1))+0.5_pReal), &
geomdim(2)*step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal), & geomdim(2)*step(2)*(mod(i/resolution(1) , resolution(2))+0.5_pReal), &
geomdim(3)*step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal), & geomdim(3)*step(3)*(mod(i/resolution(1)/resolution(2), resolution(3))+0.5_pReal), &
theGrain, ' 1' theGrain, ' 1'
enddo enddo
close(20) close(20)
close(21) close(21)
print*, 'voronoi tesselation done.' print*, 'voronoi tesselation done.'
if (all(grainCheck)) then if (all(grainCheck)) then
print*, 'all grains mapped!' print*, 'all grains mapped!'
else else
print*, 'only',count(grainCheck),'grains mapped!' print*, 'only',count(grainCheck),'grains mapped!'
endif endif
end program voronoi end program voronoi