/usr/share/elmerpost/tcl/loadsingle is in elmer-common 6.1.0.svn.5396.dfsg-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | function loadfl(file)
{
fp = fopen( file,"r" );
xx = fscanf( fp,"%lf %lf %lf %lf\n" );
rows = xx(2);
cols = xx(3);
str = fread( fp,rows*cols*4 );
fclose(fp);
_loadfl = rows cols % cvtmat( str,"float" );
}
function sicoreadfile(basename,slice,noftimes)
import nodes
export Velocity,Velocity_abs, Temperature, Height, Drainage, Melt, Mask, Ncts, Flux, Flux_abs, Age, times
{
if ( ~exists("slice") ) slice = 1;
!
! if you have filenames like file00,file01,file02, etc...
!
fname = sprintf( "%02g", slice );
suffix = ".dat"
fname = basename fname suffix;
x = loadfl(fname);
! after which you have f.ex. temp (after a modification of the original
! extract function to change the names of the exported variables) for
! current temperature, you can add this to overall temperature:
n = time(noftimes);
Height(n)=x(time(0),0);
Velocity(0,n)=x(time(0),1);
Velocity(1,n)=x(time(0),2);
Velocity(2,n)=x(time(0),3);
Drainage(n)=x(time(0),4);
Melt(n)=x(time(0),5);
Mask(n)=x(time(0),6);
Ncts(n)=x(time(0),7);
Temperature(n)=x(time(0),8);
Age(n)=x(time(0),9);
Flux(0,n)=x(time(0),10);
Flux(1,n)=x(time(0),11);
Flux(2,n)=0.0;
! set timestep info for timestep panel:
! in principle first value here is meant to be a running index,
! second value simulation timestep index and third simulation time
times(0:2,noftimes) = noftimes;
! and recompute absolute values of vectors:
! don't have to do this in the extract function anymore...
Velocity_abs = sqrt(vdot(Velocity,Velocity));
Flux_abs = sqrt(vdot(Flux, Flux));
str = sprintf("set NumberOfTimesteps %g", noftimes );
tcl( str );
}
|