Skip to content

Commit

Permalink
Added post- and pre- processing utilities for faults with split nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Surendra Somala committed May 23, 2013
1 parent c024ff2 commit 8197f42
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
61 changes: 61 additions & 0 deletions utils/FSEM3D_snapshot.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
%FSEM3D_SNAPSHOT reads fault data at a given time
%
% d = FSEM3D_snapshot(isnap, [dir, fault])
%
% INPUTS isnap snapshot index, as in Snapshot*.bin file names
% dir ["."] directory containing the SPECFEM3D output data Snapshot*.bin
% fault [1] fault id
%
% OUTPUTS d structure containing fault fields:
% X,Y,Z fault node coordinates (km)
% Dx,Dz slip (m)
% Vx,Vz slip rate (m/s)
% Tx,Ty,Tz stress change (MPa)
% S slip "state" variable in friction law (m)
% Sg strength relative to initial stress (MPa)
% Trup rupture time (s)
% Tpz process zone time, when slip=Dc (s)
%
% Jean-Paul Ampuero [email protected] modified by
% Percy Galvez [email protected] 19/01/2011.
%
% WARNING : Works only for single precision snapshot files.

function d = FSEM3D_snapshot(isnap,DATA_DIR,fault)

NDAT = 14;

if nargin<2, DATA_DIR = '.'; end
if nargin<3, fault = 1; end

BinFile = sprintf('%s/Snapshot%u_F%u.bin',DATA_DIR,isnap,fault);

if ~exist(BinFile,'file'), error(sprintf('File %s does not exist',BinFile)), end
fid=fopen(BinFile);
BinRead = fread(fid,[1,inf],'single')' ;
fclose(fid);

BinRead = reshape( BinRead(:),length(BinRead)/NDAT, NDAT);
BinRead = BinRead(2:end-1,:);

% Reorder fault nodes (lexicographic z,x)
%[LOC,IND] = sortrows( BinRead(:,[1 3]) );
%BinRead = BinRead(IND,:);

d.X = BinRead(:,1)/1e3; % in km
d.Y = BinRead(:,2)/1e3; % in km
d.Z = BinRead(:,3)/1e3; % in km
d.Dx = BinRead(:,4);
d.Dz = BinRead(:,5);
d.Vx = BinRead(:,6);
d.Vz = BinRead(:,7);
d.Tx = BinRead(:,8); % in MPa
d.Ty = BinRead(:,9);
d.Tz = BinRead(:,10); % in MPa
d.S = BinRead(:,11);
d.Sg = BinRead(:,12); % in MPa
d.Trup = BinRead(:,13);
d.Tpz = BinRead(:,14);


return
31 changes: 31 additions & 0 deletions utils/critical_timestep.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
% CRITICAL_TIMESTEP Computes the critical timestep in 3D, assuming:
% purely elastic medium
% the leapfrog time scheme
% a cube element (same size for all faces)
%
% SYNTAX dtc = critical_timestep(csp,h,ngll)
%
% INPUT cp P wave speed (in m/s)
% h element size (in m)
% ngll number of GLL nodes per spectral element edge (2 to 20)
%
% OUTPUT dtc critical timestep
%
function dtc = critical_timestep(csp,h,ngll)

DIM = 3; % dimension

if ngll<2 | ngll>20, error('ngll must be from 2 to 20'); end

% tabulated values of critical frequency (non-dimensional, 1D)
% Omega_max(p) = Omega_max(ngll-1)
Omega_max = [2.0000000e+00 4.8989795e+00 8.6203822e+00 1.3540623e+01 1.9797952e+01 2.7378050e+01 ...
3.6256848e+01 4.6421894e+01 5.7867306e+01 7.0590158e+01 8.4588883e+01 9.9862585e+01 ...
1.1641072e+02 1.3423295e+02 1.5332903e+02 1.7369883e+02 1.9534221e+02 2.1825912e+02 2.4244948e+02];

% stability factor por leapfrog timescheme
C = 2;

% critical time step,
% assumes a cube element
dtc = C*h/csp/sqrt(DIM)/Omega_max(ngll-1);

0 comments on commit 8197f42

Please sign in to comment.