[cig-commits] r15968 - in long/3D/SNAC/trunk/Snac/plugins: . plasticSPR

echoi at geodynamics.org echoi at geodynamics.org
Sat Nov 14 11:14:54 PST 2009


Author: echoi
Date: 2009-11-14 11:14:52 -0800 (Sat, 14 Nov 2009)
New Revision: 15968

Added:
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Make.mm
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Makefile.def
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Plastic.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.c
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.h
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/makefile
   long/3D/SNAC/trunk/Snac/plugins/plasticSPR/types.h
Log:
A new version of plastic plugin that makes use of the new SPR-based remesher.
	- Will remap plastic strain by recovering it on nodes of a deformed mesh, 
		interpolating the nodal field betwenn the old and new meshes, 
		and computing the average at each tetrahedron's barycenter.




Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,479 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Constitutive.c 3274 2007-03-27 20:25:29Z EunseoChoi $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Element.h"
+#include "Constitutive.h"
+#include "Register.h"
+#include <math.h>
+#include <string.h>
+#include <assert.h>
+
+#ifndef PI
+#ifndef M_PIl
+#ifndef M_PI
+#define PI 3.14159265358979323846
+#else
+#define PI M_PI
+#endif
+#else
+#define PI M_PIl
+#endif
+#endif
+
+//#define DEBUG
+
+void SnacPlastic_Constitutive( void* _context, Element_LocalIndex element_lI ) {
+	Snac_Context			*context = (Snac_Context*)_context;
+	Snac_Element			*element = Snac_Element_At( context, element_lI );
+	SnacPlastic_Element		*plasticElement = ExtensionManager_Get( context->mesh->elementExtensionMgr, element, SnacPlastic_ElementHandle );
+	const Snac_Material		*material = &context->materialProperty[element->material_I];
+
+	MeshLayout*			meshLayout = (MeshLayout*)context->meshLayout;
+	HexaMD*				decomp = (HexaMD*)meshLayout->decomp;
+	IJK				ijk;
+	Element_GlobalIndex		element_gI = _MeshDecomp_Element_LocalToGlobal1D( decomp, element_lI );
+	RegularMeshUtils_Element_1DTo3D( decomp, element_gI, &ijk[0], &ijk[1], &ijk[2] );
+
+	if ( material->rheology & Snac_Material_Plastic ) {
+		Tetrahedra_Index	tetra_I;
+		double			cohesion = 0.0f;
+		double			frictionAngle = 0.0f;
+		double			dilationAngle = 0.0f;
+		double			hardening = 0.0f;
+		double			sphi = 0.0f;
+		double			spsi = 0.0f;
+		double			st = 0.0f;
+		const double		degrad = PI / 180.0f;
+		double			totalVolume=0.0f,depls=0.0f;
+		int principal_stresses(StressTensor* stress,double sp[],double cn[3][3]);
+
+		unsigned int	        i;
+		double                  tmp = 0.0f;
+		double		        anphi = 0.0f;
+		double		        anpsi = 0.0f;
+		const double		a1 = material->lambda + 2.0f * material->mu ;
+		const double		a2 = material->lambda ;
+		int                     ind=0;
+
+                static char             plasticStrainReportedFlag=0;
+
+		/* 
+		 *   Work out the plastic material properties of this element 
+		*/
+		for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
+			double		        cn[3][3] = {{0.0,0.0,0.0},{0.0,0.0,0.0},{0.0,0.0,0.0}};
+			double		        s[3] = {0.0,0.0,0.0};
+			double			alam=0.0f, dep1, dep2, dep3, depm;
+			double			fs,ft,aP,sP,h;
+			unsigned int		k, m, n;
+			double		        trace_strain;
+			StressTensor*		stress = &element->tetra[tetra_I].stress;
+			StrainTensor*		strain = &element->tetra[tetra_I].strain;
+			/*  
+			 *  CPS bug fix:  was set to zero, thus not picking up plastic strain weakening except at t=0
+			 */
+			Strain		        plasticStrain = plasticElement->plasticStrain[tetra_I];
+
+
+			/* 
+			 *  Compute elastic stress first 
+			 */
+			trace_strain = (*strain)[0][0] + (*strain)[1][1] + (*strain)[2][2];
+
+			(*stress)[0][0] += (2.0f * material->mu) * (*strain)[0][0] + material->lambda * (trace_strain );
+			(*stress)[1][1] += (2.0f * material->mu) * (*strain)[1][1] + material->lambda * (trace_strain );
+			(*stress)[2][2] += (2.0f * material->mu) * (*strain)[2][2] + material->lambda * (trace_strain );
+			(*stress)[0][1] += (2.0f * material->mu) * (*strain)[0][1];
+			(*stress)[0][2] += (2.0f * material->mu) * (*strain)[0][2];
+			(*stress)[1][2] += (2.0f * material->mu) * (*strain)[1][2];
+
+			principal_stresses(stress,s,cn);
+
+			/*
+			 *  Calculate material props (friction angle, cohesion, etc) from piecewise-linear
+			 *    functions defined in terms of plastic strain.
+			 */
+			Journal_DFirewall( (material->plstrain[0]==0.0), context->snacError, "The initial segment should start from the plastic strain of 0.0" );
+			Journal_OFirewall( (material->plstrain[0]==0.0), context->snacError,  __FILE__, __func__, __LINE__,
+							   "timeStep=%u rank=%u: The initial segment should start from the plastic strain of 0.0.",
+							   context->timeStep, context->rank );
+			for( i = 0; i < material->nsegments; i++ ) {
+				const double pl1 = material->plstrain[i];
+				const double pl2 = material->plstrain[i+1];
+
+				if( plasticStrain >= pl1 && plasticStrain <= pl2 ) {
+					const double	tgf = (material->frictionAngle[i+1] - material->frictionAngle[i]) / (pl2 - pl1);
+					const double	tgd = (material->dilationAngle[i+1] - material->dilationAngle[i]) / (pl2 - pl1);
+					const double	tgc = (material->cohesion[i+1] - material->cohesion[i]) / (pl2 - pl1);
+
+					frictionAngle = material->frictionAngle[i] + tgf * (plasticStrain - pl1);
+					dilationAngle = material->dilationAngle[i] + tgd * (plasticStrain - pl1);
+					cohesion = material->cohesion[i] + tgc * (plasticStrain - pl1);
+					hardening = tgc;
+					break;
+				} else if(i==material->nsegments-1 && plasticStrain > pl2) {
+				    /*
+				     *  CPS mod:  one extra test if pl strain is outside piecewise range, is last piece, and 
+				     *    has pl strain larger than piece  -  then set physical params to maxima for this piece
+				     *  Purpose:  to prevent crazy behavior for extreme plastic strains
+				     */
+				    frictionAngle = material->frictionAngle[material->nsegments];
+				    dilationAngle = material->dilationAngle[material->nsegments];
+				    cohesion = material->cohesion[material->nsegments];
+				    hardening = 0.0;
+					break;
+				}
+			}
+
+			sphi = sin( frictionAngle * degrad );
+			spsi = sin( dilationAngle * degrad );
+			anphi = (1.0f + sphi) / (1.0f - sphi);
+			anpsi = (1.0f + spsi) / (1.0f - spsi);
+			
+			if( frictionAngle >= 0.0f ) {
+				st = material->ten_off;
+				if( frictionAngle > 0.0) {
+					tmp = cohesion / tan( frictionAngle * degrad);
+					if(tmp < st)st=tmp;
+				}
+			}
+			else {
+				/* frictionAngle < 0.0 violates second law of thermodynamics */
+				abort();
+			}
+			
+			
+			/* CHECK FOR COMPOSITE YIELD CRITERION  */
+			fs = s[0] - s[2] * anphi + 2 * cohesion * sqrt( anphi );
+			ft = s[2] - st;
+                        ind=0;
+			if( fs < 0.0f || ft > 0.0f ) {
+                                if(!plasticStrainReportedFlag) {
+                                        fprintf(stderr, "r=%d, ts=%d:  *** Plastic failure *** at (%d, %d, %d)\n",context->rank, context->timeStep, ijk[0],ijk[1],ijk[2]);
+                                        plasticStrainReportedFlag=1;
+                                }
+				/*! Failure: shear or tensile */
+				ind=1;
+				aP = sqrt( 1.0f + anphi * anphi ) + anphi;
+				sP = st * anphi - 2 * cohesion * sqrt( anphi );
+				h = s[2] - st + aP * ( s[0] - sP );
+				
+				if( h < 0.0f ) {
+					/* !shear failure  */
+					alam = fs / ( a1 - a2 * anpsi + a1 * anphi * anpsi - a2 * anphi + 2.0*sqrt(anphi)*hardening );
+					s[0] -= alam * ( a1 - a2 * anpsi );
+					s[1] -= alam * a2 * ( 1.0f - anpsi );
+					s[2] -= alam * ( a2 - a1 * anpsi );
+					dep1 = alam;
+					dep2 = 0.0f;
+					dep3 = -alam * anpsi;
+				}
+				else {
+					/* tensile failure */
+					alam = ft / a1;
+					s[0] -= alam * a2;
+					s[1] -= alam * a2;
+					s[2] -= alam * a1;
+					dep1 = 0.0f;
+					dep2 = 0.0f;
+					dep3 = alam;
+				}
+			}
+			else {
+				/* ! no failure - just elastic increament */
+
+				dep1 = 0.0f;
+				dep2 = 0.0f;
+				dep3 = 0.0f;
+			}
+
+			depm=0.0;
+			if(ind) {
+				/* Second invariant of accumulated plastic increament  */
+				depm = ( dep1 + dep2 + dep3 ) / 3.0f;
+				plasticElement->plasticStrain[tetra_I] += sqrt( 0.5f * ((dep1-depm) * (dep1-depm) + (dep2-depm) * (dep2-depm) + (dep3-depm) * (dep3-depm) + depm*depm) );
+
+				memset( stress, 0, sizeof((*stress)) );
+				/* Resolve back to global axes  */
+				for( m = 0; m < 3; m++ ) {
+					for( n = m; n < 3; n++ ) {
+						for( k = 0; k < 3; k++ ) {
+							(*stress)[m][n] += cn[k][m] * cn[k][n] * s[k];
+						}
+					}
+				}
+			}
+			depls += plasticElement->plasticStrain[tetra_I]*element->tetra[tetra_I].volume;
+			totalVolume += element->tetra[tetra_I].volume;
+/* 			if(element_lI==738) fprintf(stderr,"   *****  %d: depm=%g  acc plastic strain=%g\n", tetra_I, depm, element->tetra[tetra_I].volume); */
+		}
+		/* volume-averaged accumulated plastic strain, aps */
+		plasticElement->aps = depls/totalVolume;
+/* 		if(element_lI==738) fprintf(stderr,"   *****  acc plastic strain=%g\n", plasticElement->aps); */
+	}
+}
+
+int principal_stresses(StressTensor* stress, double sp[3], double cn[3][3])
+{
+
+	double **a,**v,*d;
+	int i,j;
+
+	a = dmatrix(1,3,1,3);
+	v = dmatrix(1,3,1,3);
+	d = dvector(1,3);
+
+	a[1][1] = (*stress)[0][0];
+	a[2][2] = (*stress)[1][1];
+	a[3][3] = (*stress)[2][2];
+	a[1][2] = (*stress)[0][1];
+	a[1][3] = (*stress)[0][2];
+	a[2][3] = (*stress)[1][2];
+	a[2][1] = a[1][2];
+	a[3][1] = a[1][3];
+	a[3][2] = a[2][3];
+
+	jacobi(a,d,v);
+
+	d[1] *= -1.0f;
+	d[2] *= -1.0f;
+	d[3] *= -1.0f;
+
+	eigsrt(d,v);
+
+	d[1] *= -1.0f;
+	d[2] *= -1.0f;
+	d[3] *= -1.0f;
+
+	for(i=0;i<3;i++) {
+		sp[i] = d[i+1];
+		for(j=0;j<3;j++) {
+			cn[i][j] = v[j+1][i+1];
+		}
+	}
+
+	free_dmatrix(a,1,3,1,3);
+	free_dmatrix(v,1,3,1,3);
+	free_dvector(d,1,3);
+
+	return(1);
+}
+
+int jacobi(double** a, double* d, double** v)
+{
+
+	int nrot = 0;
+	const unsigned int nmax = 100, n = 3;
+	double b[nmax], z[nmax], tresh,sm,g,h,t,theta,c,s,tau;
+
+	int i,j,ip,iq;
+
+	for(ip=1;ip<=n;ip++) {
+		for(iq=1;iq<=n;iq++) v[ip][iq] = 0.0f;
+		v[ip][ip] = 1.0f;
+	}
+
+	for(ip=1;ip<=n;ip++) {
+		b[ip] = d[ip] = a[ip][ip];
+		z[ip] = 0.0f;
+	}
+
+	for(i=1;i<=50;i++) {
+		sm = 0.0f;
+		for(ip=1;ip<=n-1;ip++) {
+			for(iq=ip+1;iq<=n;iq++)
+				sm += fabs(a[ip][iq]);
+		}
+		if(sm == 0.0f)
+			return(0);
+
+		if(i < 4) {
+			tresh = 0.2f * sm / ( n*n );
+		}
+		else {
+			tresh = 0.0f;
+		}
+
+		for(ip=1;ip<=n-1;ip++) {
+			for(iq=ip+1;iq<=n;iq++) {
+				g = 100.0f*fabs(a[ip][iq]);
+				if( (i > 4) && (double)(fabs(d[ip])+g) == (double)fabs(d[ip]) && (double)(fabs(d[iq])+g) == (double)fabs(d[iq]))
+					a[ip][iq] = 0.0f;
+				else if( fabs(a[ip][iq]) > tresh ) {
+					h = d[iq] - d[ip];
+					if( (fabs(h)+g) == fabs(h) )
+						t = a[ip][iq] / h;
+					else {
+						theta = 0.5f * h / (a[ip][iq]);
+						t = 1.0f / (fabs(theta) + sqrt(1.0f + theta*theta));
+						if(theta < 0.0f) t *= -1.0f;
+					}
+					c = 1.0f / sqrt(1.0f + t*t);
+					s = t * c;
+					tau = s / (1.0f + c);
+					h = t * a[ip][iq];
+					z[ip] -= h;
+					z[iq] += h;
+					d[ip] -= h;
+					d[iq] += h;
+					a[ip][iq] = 0.0f;
+					for(j=1;j<=ip-1;j++) {
+						ROTATE(a,j,ip,j,iq);
+					}
+					for(j=ip+1;j<=iq-1;j++) {
+						ROTATE(a,ip,j,j,iq);
+					}
+					for(j=iq+1;j<=n;j++) {
+						ROTATE(a,ip,j,iq,j);
+					}
+					for(j=1;j<=n;j++) {
+						ROTATE(v,j,ip,j,iq);
+					}
+
+					++nrot;
+				}
+			}
+		}
+		for(ip=1;ip<=n;ip++) {
+			b[ip] += z[ip];
+			d[ip] = b[ip];
+			z[ip] = 0.0f;
+		}
+	}
+	assert(i<50);
+
+	return 1;
+}
+
+
+int eigsrt(double* d, double** v)
+{
+
+	const unsigned int n = 3;
+	int i,j,k;
+	double p;
+
+	for(i=1;i<n;i++) {
+		k = i;
+		p = d[i];
+
+		for(j=i+1;j<=n;j++) {
+			if(d[j] >= p) {
+				k = j;
+				p = d[j];
+			}
+		}
+		if(k != i) {
+			d[k] = d[i];
+			d[i] = p;
+			for(j=1;j<=n;j++) {
+				p = v[j][i];
+				v[j][i] = v[j][k];
+				v[j][k] = p;
+			}
+		}
+	}
+	return(0);
+}
+
+double **dmatrix(long nrl, long nrh, long ncl, long nch)
+	/* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
+{
+	long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
+	double **m;
+
+	/* allocate pointers to rows */
+	m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
+	if (!m) nrerror("allocation failure 1 in matrix()");
+	m += NR_END;
+	m -= nrl;
+	/* allocate rows and set pointers to them */
+	m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
+	if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
+	m[nrl] += NR_END;
+	m[nrl] -= ncl;
+	for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
+	/* return pointer to array of pointers to rows */
+	return m;
+}
+
+
+void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch)
+	/* free a double matrix allocated by dmatrix() */
+{
+	free((FREE_ARG) (m[nrl]+ncl-NR_END));
+	free((FREE_ARG) (m+nrl-NR_END));
+}
+
+
+void nrerror(char error_text[])
+{
+	fprintf(stderr,"Numerical Recipes run-time error...\n");
+	fprintf(stderr,"%s\n",error_text);
+	fprintf(stderr,"...now exiting to system...\n");
+	exit(1);
+}
+
+
+double *dvector(long nl, long nh)
+	/* allocate a double vector with subscript range v[nl..nh] */
+{
+	double *v;
+	v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
+	if (!v) nrerror("allocation failure in dvector()");
+	return v-nl+NR_END;
+}
+
+int *ivector(long nl, long nh)
+	/* allocate an int vector with subscript range v[nl..nh] */
+{
+	int *v;
+	v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
+	if (!v) nrerror("allocation failure in ivector()");
+	return v-nl+NR_END;
+}
+
+void free_dvector(double *v, long nl, long nh)
+	/* free a double vector allocated with dvector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}
+
+void free_ivector(int *v, long nl, long nh)
+	/* free an int vector allocated with ivector() */
+{
+	free((FREE_ARG) (v+nl-NR_END));
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Constitutive.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,68 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**	Calculates the plastic properties for a given element. 
+**
+** Assumptions:
+**	None as yet.
+**
+** Comments:
+**	None as yet.
+**
+** $Id: Constitutive.h 3274 2007-03-27 20:25:29Z EunseoChoi $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#define ROTATE(a,i,j,k,l) g=a[i][j];h=a[k][l];a[i][j]=g-s*(h+g*tau);\
+    a[k][l]=h+s*(g-h*tau);
+#define SWAP(g,h) {y=(g);(g)=(h);(h)=y;}
+#define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
+
+
+#define TINY 1.0e-20
+#define RADIX 2.0
+#define NR_END 1
+#define FREE_ARG char*	
+ 
+#ifndef __SnacPlastic_h__
+#define __SnacPlastic_h__
+	
+	void SnacPlastic_Constitutive( void* context, Element_LocalIndex element_lI );
+	
+	double** dmatrix(long nrl, long nrh, long ncl, long nch);
+	double *dvector(long nl, long nh);
+	int *ivector(long nl, long nh);
+	void free_ivector(int *v, long nl, long nh);
+	void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
+	void free_dvector(double *v, long nl, long nh);
+	void nrerror(char error_text[]);
+	int jacobi(double** a, double* d, double** v);
+	int eigsrt(double* d, double** v);
+#endif /* __SnacPlastic_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,69 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: ConstructExtensions.c 2498 2005-01-07 03:57:00Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Context.h"
+#include "Register.h"
+#include "ConstructExtensions.h"
+#include <assert.h>
+#include <limits.h>
+#ifndef PATH_MAX
+	#define PATH_MAX 1024
+#endif
+
+void _SnacPlastic_ConstructExtensions( void* _context, void* data ) {
+	Snac_Context*				context = (Snac_Context*)_context;
+	SnacPlastic_Context*		contextExt = ExtensionManager_Get(
+												context->extensionMgr,
+												context,
+												SnacPlastic_ContextHandle );
+	char						tmpBuf[PATH_MAX];
+
+#if DEBUG
+	printf( "In %s()\n", __func__ );
+#endif
+
+	/* Prepare the dump and checkpoint file */
+	sprintf( tmpBuf, "%s/plStrain.%u", context->outputPath, context->rank );
+	if( (contextExt->plStrainOut = fopen( tmpBuf, "w+" )) == NULL ) {
+		assert( contextExt->plStrainOut /* failed to open file for writing */ );
+		abort();
+	}
+	sprintf( tmpBuf, "%s/plStrainCP.%u", context->outputPath, context->rank );
+	if( (contextExt->plStrainCheckpoint = fopen( tmpBuf, "w+" )) == NULL ) {
+		assert( contextExt->plStrainCheckpoint /* failed to open file for writing */ );
+		abort();
+	}
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/ConstructExtensions.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,45 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: ConstructExtensions.h 1677 2004-07-20 10:30:34Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_ConstructExtensions_h__
+#define __SnacPlastic_ConstructExtensions_h__
+	
+	void _SnacPlastic_ConstructExtensions( void* _context, void* data );
+	
+#endif /* __SnacPlastic_ConstructExtensions_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,45 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Context.c 1792 2004-07-30 05:42:39Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Context.h"
+#include <stdio.h>
+
+void SnacPlastic_Context_Print( void* _context ) {
+	SnacPlastic_Context*	self = (SnacPlastic_Context*)_context;
+	
+	printf( "SnacPlastic_Context:\n" );
+	printf( "\tplstrain (ptr): %p", self->plStrainOut );
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Context.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,53 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: Context.h 1677 2004-07-20 10:30:34Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_Context_h__
+#define __SnacPlastic_Context_h__
+	
+	/* Context Information */
+	struct _SnacPlastic_Context {
+		/* Dumping */
+		FILE*				plStrainOut;
+		FILE*				plStrainCheckpoint;
+	};
+	
+	/* Print the contents of the context extension */
+	void SnacPlastic_Context_Print( void* _context );
+	
+#endif /* __SnacPlastic_Context_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,49 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Element.c 1792 2004-07-30 05:42:39Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Element.h"
+#include <stdio.h>
+
+void SnacPlastic_Element_Print( void* element ) {
+	SnacPlastic_Element*	self = (SnacPlastic_Element*)element;
+	Tetrahedra_Index	tetra_I;
+	
+	printf( "SnacPlastic_Element:\n" );
+	printf( "\tplasticStrain: " );
+	for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
+		printf( "%g, ", self->plasticStrain[tetra_I] );
+	}
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Element.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,53 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**	Snac plastic properties for an element.
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: Element.h 1720 2004-07-22 18:33:41Z EunseoChoi $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_Element_h__
+#define __SnacPlastic_Element_h__
+
+	/* Element Information */
+	struct _SnacPlastic_Element {
+		Strain			plasticStrain[Tetrahedra_Count];
+		Strain			aps;
+	};
+
+	/* Print the contents of an Element */
+	void SnacPlastic_Element_Print( void* element );
+
+#endif /* __SnacPlastic_Element_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,114 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: InitialConditions.c 2498 2005-01-07 03:57:00Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Element.h"
+#include "InitialConditions.h"
+#include "Register.h"
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+void SnacPlastic_InitialConditions( void* _context ) {
+	Snac_Context*			context = (Snac_Context*)_context;
+	Element_LocalIndex		element_lI;
+	Dictionary_Entry_Value* materialList = Dictionary_Get( context->dictionary, "materials" );
+	int						PhaseI = 0;
+#ifdef DEBUG
+	printf( "In: _SnacPlastic_InitialConditions( void* )\n" );
+#endif
+
+	if( materialList ) {
+		Dictionary_Entry_Value* materialEntry = Dictionary_Entry_Value_GetFirstElement( materialList );
+		/* loop around the  phases to initialize rheology */
+		while( materialEntry ) {
+			context->materialProperty[PhaseI].rheology |= Snac_Material_Plastic;
+			PhaseI++;
+			materialEntry                               = materialEntry->next;
+		}
+	}
+	else
+		context->materialProperty[PhaseI].rheology |= Snac_Material_Plastic;
+
+	if( context->restartTimestep > 0 ) {
+		FILE*				plStrainIn;
+		char				path[PATH_MAX];
+		
+		sprintf(path, "%s/snac.plStrain.%d.%06d.restart",context->outputPath,context->rank,context->restartTimestep);
+		Journal_Firewall( (plStrainIn = fopen(path,"r")) != NULL, "Can't find %s", path );
+		
+		/* read in restart file to reconstruct the previous plastic strain.*/
+		for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
+			Snac_Element*				element = Snac_Element_At( context, element_lI );
+			SnacPlastic_Element*		plasticElement = ExtensionManager_Get( context->mesh->elementExtensionMgr, element,
+															SnacPlastic_ElementHandle );
+			const Snac_Material* 		material = &context->materialProperty[element->material_I];
+
+			if( material->yieldcriterion == mohrcoulomb ) {
+				Tetrahedra_Index	tetra_I;
+				double              depls = 0.0f;
+				double              totalVolume = 0.0f;
+				
+				for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
+					double			tetraPlStrain;
+
+					fscanf( plStrainIn, "%le", &tetraPlStrain );
+					plasticElement->plasticStrain[tetra_I] = tetraPlStrain;
+					depls += plasticElement->plasticStrain[tetra_I]*element->tetra[tetra_I].volume;
+					totalVolume += element->tetra[tetra_I].volume;
+				}
+				/* volume-averaged accumulated plastic strain, aps */
+				plasticElement->aps = depls/totalVolume;
+			}//if(mohrcoulomb)
+		}//for elements
+		if( plStrainIn )
+			fclose( plStrainIn );
+	}//if restarting
+	else {
+		/* Set the plastic element initial conditions */
+		for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
+			Snac_Element*		element = Snac_Element_At( context, element_lI );
+			SnacPlastic_Element*	plasticElement = ExtensionManager_Get( context->mesh->elementExtensionMgr, element, 
+																		   SnacPlastic_ElementHandle );
+			Tetrahedra_Index	tetra_I;
+			
+			for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
+				plasticElement->plasticStrain[tetra_I] = 0.0f;
+			}
+			plasticElement->aps = 0.0f;
+		}
+	}
+}
+		

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/InitialConditions.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,45 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: InitialConditions.h 1084 2004-03-26 11:17:10Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_InitialConditions_h__
+#define __SnacPlastic_InitialConditions_h__
+	
+	void SnacPlastic_InitialConditions( void* _context );
+	
+#endif /* __SnacPlastic_InitialConditions_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Make.mm
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Make.mm	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Make.mm	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,67 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003, 
+##	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+##	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+##	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+##
+## Authors:
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+##	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+##	Luc Lavier, Research Scientist, Caltech.
+##
+## 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 the
+## Free Software Foundation; either version 2, or (at your option) any
+## later version.
+## 
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+## 
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+##
+## $Id: Make.mm 2921 2005-05-10 06:44:06Z EunseoChoi $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+include Makefile.def
+
+PROJECT = Snac
+PACKAGE = ${def_mod}module
+
+PROJ_LIB = $(BLD_LIBDIR)/$(PACKAGE).a
+PROJ_DLL = $(BLD_LIBDIR)/$(PACKAGE).$(EXT_SO)
+PROJ_TMPDIR = $(BLD_TMPDIR)/$(PROJECT)/$(PACKAGE)
+PROJ_CLEAN += $(PROJ_LIB) $(PROJ_DLL)
+PROJ_INCDIR = $(BLD_INCDIR)/${def_inc}
+
+PROJ_SRCS = ${def_srcs}
+PROJ_CC_FLAGS += -I$(BLD_INCDIR)/$(PROJECT) -I$(BLD_INCDIR)/Snac -I$(BLD_INCDIR)/StGermain -I$(STGERMAIN_INCDIR)/ -I$(STGERMAIN_INCDIR)/StGermain `xml2-config --cflags` -DCURR_MODULE_NAME=\"${def_mod}\"
+PROJ_LIBRARIES = -L$(BLD_LIBDIR) -L$(STGERMAIN_LIBDIR)/ -lSnac -lStGermain `xml2-config --libs` $(MPI_LIBPATH) $(MPI_LIBS)
+LCCFLAGS = 
+
+# I keep file lists to build a monolith .so from a set of .a's
+PROJ_OBJS_IN_TMP = ${addprefix $(PROJECT)/$(PACKAGE)/, ${addsuffix .o, ${basename $(PROJ_SRCS)}}}
+PROJ_OBJLIST = $(BLD_TMPDIR)/$(PROJECT).$(PACKAGE).objlist
+
+all: $(PROJ_LIB) DLL createObjList export
+
+DLL: product_dirs $(PROJ_OBJS)
+	$(CC) -o $(PROJ_DLL) $(PROJ_OBJS) $(COMPILER_LCC_SOFLAGS) $(LCCFLAGS) $(PROJ_LIBRARIES) $(EXTERNAL_LIBPATH) $(EXTERNAL_LIBS)
+
+
+
+createObjList:: 
+	@echo ${PROJ_OBJS_IN_TMP} | cat > ${PROJ_OBJLIST}
+
+#export:: export-headers
+export:: export-headers export-libraries
+EXPORT_HEADERS = ${def_hdrs}
+EXPORT_LIBS = $(PROJ_LIB) $(PROJ_DLL)
+
+check::

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Makefile.def
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Makefile.def	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Makefile.def	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,59 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003, 
+##	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+##	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+##	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+##
+## Authors:
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+##	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+##	Luc Lavier, Research Scientist, Caltech.
+##	Luc Lavier, Caltech.
+##
+## 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 the
+## Free Software Foundation; either version 2, or (at your option) any
+## later version.
+## 
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+## 
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+##
+## $Id: Makefile.def 2713 2005-03-01 19:14:08Z EunseoChoi $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 
+def_mod = SnacPlastic
+def_inc = Snac/Plastic
+
+def_srcs = \
+	Node.c \
+	Element.c \
+	Context.c \
+	ConstructExtensions.c \
+	Constitutive.c \
+	Output.c \
+	Register.c \
+	InitialConditions.c \
+	Remesh.c \
+
+def_hdrs = \
+	Node.h \
+	Element.h \
+	Context.h \
+	ConstructExtensions.h \
+	Constitutive.h \
+	Output.h \
+	Register.h \
+	InitialConditions.h \
+	Remesh.h \
+	Plastic.h \
+	types.h
+

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,52 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Mesh.c 3095 2005-07-13 09:50:46Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Mesh.h"
+
+#include <stdio.h>
+
+
+/*
+** Due to the rewrite this func is severely useless.  Need to fix it.
+*/
+
+void SnacPlastic_Mesh_Print( void* mesh, Stream* stream ) {
+	SnacPlastic_Mesh*	self = (SnacPlastic_Mesh*)mesh;
+
+	Journal_Printf( stream, "SnacPlastic_Mesh:\n" );
+
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Mesh.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,55 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**	Snac exchanger properties extensions to the mesh construct.
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: Mesh.h 3173 2005-11-21 23:47:09Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_Mesh_h__
+#define __SnacPlastic_Mesh_h__
+
+
+	/* Mesh Information */
+	struct _SnacPlastic_Mesh {
+		Snac_Node*	newNodes;
+	};
+	
+	/* Print the contents of a mesh */
+	void SnacPlastic_Mesh_Print( void* mesh, Stream* stream );
+	
+
+#endif /* __SnacPlastic_Mesh_h__ */
+

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,47 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Node.c 1792 2004-07-30 05:42:39Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Node.h"
+#include <stdio.h>
+
+void SnacPlastic_Node_Print( void* node ) {
+	SnacPlastic_Node*	self = (SnacPlastic_Node*)node;
+	Tetrahedra_Index	tetra_I;
+	
+	printf( "SnacPlastic_Node:\n" );
+	printf( "\tplasticStrainSPR: " );
+	printf( "%g, ", self->plStrainSPR );
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Node.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,52 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**	Snac plastic properties for an element.
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: Node.h 1720 2004-07-22 18:33:41Z EunseoChoi $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_Node_h__
+#define __SnacPlastic_Node_h__
+
+	/* Node Information */
+	struct _SnacPlastic_Node {
+		Strain			plStrainSPR;
+	};
+
+	/* Print the contents of an Node */
+	void SnacPlastic_Node_Print( void* element );
+
+#endif /* __SnacPlastic_Node_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,108 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Output.c 2498 2005-01-07 03:57:00Z PatrickSunter $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Output.h"
+#include "Context.h"
+#include "Element.h"
+#include "Register.h"
+#include <stdio.h>
+
+
+
+void _SnacPlastic_WritePlasticStrain( void* _context ) {
+	Snac_Context*				context = (Snac_Context*) _context;
+
+	if( isTimeToDump( context ) )
+		_SnacPlastic_DumpPlasticStrain( context );
+
+	if( isTimeToCheckpoint( context ) )
+		_SnacPlastic_CheckpointPlasticStrain( context );
+
+}
+
+
+void _SnacPlastic_DumpPlasticStrain( void* _context ) {
+	Snac_Context*				context = (Snac_Context*) _context;
+	SnacPlastic_Context*		contextExt = ExtensionManager_Get(
+												context->extensionMgr,
+												context,
+												SnacPlastic_ContextHandle );
+	Element_LocalIndex			element_lI;
+	
+#if DEBUG
+	printf( "In %s()\n", __func__ );
+#endif
+	
+	for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
+		Snac_Element* 				element = Snac_Element_At( context, element_lI );
+		SnacPlastic_Element*		elementExt = ExtensionManager_Get(
+													context->mesh->elementExtensionMgr,
+													element,
+													SnacPlastic_ElementHandle );
+		float plasticStrain = elementExt->aps;
+		/* Take average of tetra plastic strain for the element */
+		fwrite( &plasticStrain, sizeof(float), 1, contextExt->plStrainOut );
+	}
+	fflush( contextExt->plStrainOut );
+}
+
+
+void _SnacPlastic_CheckpointPlasticStrain( void* _context ) {
+	Snac_Context*				context = (Snac_Context*) _context;
+	SnacPlastic_Context*		contextExt = ExtensionManager_Get(
+												context->extensionMgr,
+												context,
+												SnacPlastic_ContextHandle );
+	Element_LocalIndex			element_lI;
+
+#if DEBUG
+	printf( "In %s()\n", __func__ );
+#endif
+	
+	for( element_lI = 0; element_lI < context->mesh->elementLocalCount; element_lI++ ) {
+		Snac_Element* 				element = Snac_Element_At( context, element_lI );
+		SnacPlastic_Element*		plasticElement = ExtensionManager_Get(
+														context->mesh->elementExtensionMgr,
+														element,
+														SnacPlastic_ElementHandle );
+		Tetrahedra_Index	tetra_I;
+		for( tetra_I = 0; tetra_I < Tetrahedra_Count; tetra_I++ ) {
+			float plasticStrain = plasticElement->plasticStrain[tetra_I];
+			fwrite( &plasticStrain, sizeof(float), 1, contextExt->plStrainCheckpoint );
+		}
+	}
+	fflush( contextExt->plStrainCheckpoint );
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Output.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,39 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Output.h 1677 2004-07-20 10:30:34Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef _SnacPlastic_Output_
+#define _SnacPlastic_Output_
+
+	void _SnacPlastic_WritePlasticStrain( void* _context );
+	void _SnacPlastic_DumpPlasticStrain( void* _context );
+	void _SnacPlastic_CheckpointPlasticStrain( void* _context );
+
+#endif

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Plastic.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Plastic.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Plastic.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,55 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**	Only one can be registered at the time (limitation).
+**
+** Comments:
+**
+** $Id: Plastic.h 2202 2004-10-19 08:43:09Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_h__
+#define __SnacPlastic_h__
+	
+#include "Constitutive.h"
+#include "ConstructExtensions.h"
+#include "Context.h"
+#include "Element.h"
+#include "InitialConditions.h"
+#include "Output.h"
+#include "Plastic.h"
+#include "Register.h" 
+#include "Remesh.h"
+#include "types.h"
+
+#endif /* __SnacPlastic_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,159 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Register.c 3243 2006-10-12 09:04:00Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Node.h"
+#include "Element.h"
+#include "Mesh.h"
+#include "Context.h"
+#include "Constitutive.h"
+#include "ConstructExtensions.h"
+#include "Output.h"
+#include "InitialConditions.h"
+#include "Remesh.h"
+#include "Register.h"
+#include <stdio.h>
+
+/* Textual name of this class */
+const Type SnacPlastic_Type = "SnacPlastic";
+
+ExtensionInfo_Index SnacPlastic_NodeHandle;
+ExtensionInfo_Index SnacPlastic_ElementHandle;
+ExtensionInfo_Index SnacPlastic_MeshHandle;
+ExtensionInfo_Index SnacPlastic_ContextHandle;
+
+
+Index _SnacPlastic_Register( PluginsManager* pluginsMgr ) {
+	return PluginsManager_Submit( pluginsMgr, 
+				      SnacPlastic_Type, 
+				      "0", 
+				      _SnacPlastic_DefaultNew );
+}
+
+
+void* _SnacPlastic_DefaultNew( Name name ) {
+	return _Codelet_New( sizeof(Codelet), 
+			     SnacPlastic_Type, 
+			     _Codelet_Delete, 
+			     _Codelet_Print, 
+			     _Codelet_Copy, 
+			     _SnacPlastic_DefaultNew, 
+			     _SnacPlastic_Construct, 
+			     _Codelet_Build, 
+			     _Codelet_Initialise, 
+			     _Codelet_Execute, 
+			     _Codelet_Destroy, 
+			     name );
+}
+
+
+void _SnacPlastic_Construct( void* component, Stg_ComponentFactory* cf, void* data ) {
+	Snac_Context*	context;
+	EntryPoint* 	recoverNodeEP;
+	EntryPoint* 	interpolateNodeEP;
+	EntryPoint* 	interpolateElementEP;
+
+	/* Retrieve context. */
+	context = (Snac_Context*)Stg_ComponentFactory_ConstructByName( cf, "context", Snac_Context, True, data ); 
+
+	#ifdef DEBUG
+		printf( "In: _SnacPlastic_Register( void*, void* )\n" );
+	#endif
+	
+	/* Add extensions to nodes, elements and the context */
+	SnacPlastic_NodeHandle = ExtensionManager_Add( context->mesh->nodeExtensionMgr, SnacPlastic_Type, sizeof(SnacPlastic_Node) );
+	SnacPlastic_ElementHandle = ExtensionManager_Add( context->mesh->elementExtensionMgr, SnacPlastic_Type, sizeof(SnacPlastic_Element) );
+	SnacPlastic_MeshHandle = ExtensionManager_Add( context->meshExtensionMgr, SnacPlastic_Type, sizeof(SnacPlastic_Mesh) );
+	SnacPlastic_ContextHandle = ExtensionManager_Add( context->extensionMgr, SnacPlastic_Type, sizeof(SnacPlastic_Context) );
+	
+	#ifdef DEBUG
+		printf( "\tcontext extension handle: %u\n", SnacPlastic_ContextHandle );
+		printf( "\tmesh extension handle: %u\n", SnacPlastic_MeshHandle );
+		printf( "\tnode extension handle: %u\n", SnacPlastic_NodeHandle );
+		printf( "\telement extension handle: %u\n", SnacPlastic_ElementHandle );
+	#endif
+	
+	/* Add extensions to the entry points */
+	EntryPoint_Append( 
+		Context_GetEntryPoint( context,	Snac_EP_Constitutive ),
+		SnacPlastic_Type, 
+		SnacPlastic_Constitutive, 
+		SnacPlastic_Type );
+	EntryPoint_InsertBefore( 
+		Context_GetEntryPoint( context,	AbstractContext_EP_Initialise ),
+		"SnacTimeStepZero",
+		SnacPlastic_Type, 
+		SnacPlastic_InitialConditions,
+		SnacPlastic_Type );
+	EntryPoint_Prepend( /* Dump the initial plastic strain */
+		Context_GetEntryPoint( context, AbstractContext_EP_Execute ),
+		"SnacPlastic_Write",
+		_SnacPlastic_WritePlasticStrain,
+		SnacPlastic_Type );
+	EntryPoint_Append( /* and dump each loop */
+		Context_GetEntryPoint( context, Snac_EP_CalcStresses ),
+		"SnacPlastic_Write",
+		_SnacPlastic_WritePlasticStrain,
+		SnacPlastic_Type );
+	
+	/* Add extensions to the interpolate element entry point, but it will only exist if the remesher is loaded. */
+	recoverNodeEP = Context_GetEntryPoint( context,	"SnacRemesher_EP_RecoverNode" );
+	if( recoverNodeEP ) {
+		EntryPoint_Append(
+						  recoverNodeEP,
+						  SnacPlastic_Type,
+						  _SnacPlastic_RecoverNode,
+						  SnacPlastic_Type );
+	}
+	interpolateNodeEP = Context_GetEntryPoint( context,	"SnacRemesher_EP_InterpolateNode" );
+	if( interpolateNodeEP ) {
+		EntryPoint_Append(
+						  interpolateNodeEP,
+						  SnacPlastic_Type,
+						  _SnacPlastic_InterpolateNode,
+						  SnacPlastic_Type );
+	}
+	interpolateElementEP = Context_GetEntryPoint( context,	"SnacRemesher_EP_InterpolateElement" );
+	if( interpolateElementEP ) {
+		EntryPoint_Append( 
+						  interpolateElementEP,
+						  SnacPlastic_Type, 
+						  _SnacPlastic_InterpolateElement, 
+						  SnacPlastic_Type );
+	}
+
+	/* Construct. */
+	_SnacPlastic_ConstructExtensions( context, data );
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Register.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,59 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**	Only one can be registered at the time (limitation).
+**
+** Comments:
+**
+** $Id: Register.h 3243 2006-10-12 09:04:00Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_Register_h__
+#define __SnacPlastic_Register_h__
+	
+	/* Textual name of this class */
+	extern const Type SnacPlastic_Type;
+	
+	extern ExtensionInfo_Index SnacPlastic_NodeHandle;
+	
+	extern ExtensionInfo_Index SnacPlastic_ElementHandle;
+	
+	extern ExtensionInfo_Index SnacPlastic_ContextHandle;
+	
+	Index _SnacPlastic_Register( PluginsManager* pluginsMgr );
+
+	void* _SnacPlastic_DefaultNew( Name name );
+
+	void _SnacPlastic_Construct( void* component, Stg_ComponentFactory* cf, void* data );
+	
+#endif /* __SnacPlastic_Register_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.c
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.c	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.c	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,240 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003,
+**	Pururav Thoutireddy, 
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**      110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Pururav Thoutireddy, Staff Scientist, Caltech
+**      Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+** $Id: Remesh.c 3250 2006-10-23 06:15:18Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#include <mpi.h>
+#include <StGermain/StGermain.h>
+#include <StGermain/FD/FD.h>
+#include "Snac/Snac.h"
+#include "types.h"
+#include "Node.h"
+#include "Element.h"
+#include "Mesh.h"
+#include "Remesh.h"
+#include "Register.h"
+#include <gsl/gsl_vector.h>
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_linalg.h>
+
+
+void _SnacPlastic_RecoverNode( void* _context, unsigned nodeInd )
+{
+	Snac_Context*			context = (Snac_Context*)_context;
+	Mesh*					mesh = context->mesh;
+	NodeLayout*				nLayout = mesh->layout->nodeLayout;
+
+	Snac_Node*				node = Snac_Node_At( context, nodeInd );
+	SnacPlastic_Node*		nodeExt = ExtensionManager_Get( context->mesh->nodeExtensionMgr, 
+															node, 
+															SnacPlastic_NodeHandle );
+	Coord*					coord = Snac_NodeCoord_P( context, nodeInd );
+	Index 					nodeElementCount = context->mesh->nodeElementCountTbl[nodeInd];
+	Index 					nodeElement_I;
+	Element_DomainIndex*	elements;
+	gsl_matrix*				matA;
+	gsl_vector* 			vecaPlStrain;
+	gsl_vector* 			vecbPlStrain;
+	Index 	 	 	 	 	i; 
+		
+	/* initialize gsl vectors and matrix. */
+	matA = gsl_matrix_alloc(4,4); gsl_matrix_set_zero( matA );
+	vecaPlStrain = gsl_vector_alloc(4); gsl_vector_set_zero( vecaPlStrain );
+	vecbPlStrain = gsl_vector_alloc(4); gsl_vector_set_zero( vecbPlStrain );
+			
+	/* For each incident element, find inicident tets. */
+	for( nodeElement_I = 0; nodeElement_I < nodeElementCount; nodeElement_I++ ) {
+		Element_DomainIndex		element_dI = context->mesh->nodeElementTbl[nodeInd][nodeElement_I];
+
+		if( element_dI < mesh->elementDomainCount ) {
+			Index elementTetra_I;
+			Snac_Element* 				element = Snac_Element_At( context, element_dI );
+			SnacPlastic_Element*		elementExt = ExtensionManager_Get( context->mesh->elementExtensionMgr, 
+																		   element, 
+																		   SnacPlastic_ElementHandle );
+
+			/* Extract the element's node indices.  Note that there should always be eight of these. */
+			{
+				Element_GlobalIndex	element_gI;
+					
+				elements = Memory_Alloc_Array( Node_DomainIndex, nodeElementCount, "SnacRemesher" );
+				element_gI = Mesh_ElementMapDomainToGlobal( mesh, element_dI );
+				nLayout->buildElementNodes( nLayout, element_gI, elements );
+			}
+				
+			/* Convert global node indices to domain. */
+			{
+				unsigned	eltNode_i;
+					
+				for( eltNode_i = 0; eltNode_i < nodeElementCount; eltNode_i++ ) {
+					elements[eltNode_i] = Mesh_NodeMapGlobalToDomain( mesh, elements[eltNode_i] );
+				}
+			}
+
+			/* For each incident tetrahedron in the incident element,
+			   add up contributions to P, A, and b as in Zienkiewicz and Zhu (1992), p. 1336 */
+			for( elementTetra_I = 0; elementTetra_I < Node_Element_Tetrahedra_Count;elementTetra_I++ ) {
+				Tetrahedra_Index	tetra_I = NodeToTetra[nodeElement_I][elementTetra_I];
+				Coord	tCrds[4];
+				double 	positionP[4] = {1.0,0.0,0.0,0.0};
+				Index 	ii,jj;
+
+				/* Extract the tetrahedron's coordinates. */
+				Vector_Set( tCrds[0], mesh->nodeCoord[elements[TetraToNode[tetra_I][0]]] );
+				Vector_Set( tCrds[1], mesh->nodeCoord[elements[TetraToNode[tetra_I][1]]] );
+				Vector_Set( tCrds[2], mesh->nodeCoord[elements[TetraToNode[tetra_I][2]]] );
+				Vector_Set( tCrds[3], mesh->nodeCoord[elements[TetraToNode[tetra_I][3]]] );
+					
+				for(ii=1;ii<4;ii++)
+					for(jj=0;jj<4;jj++)
+						positionP[ii] += (0.25f * tCrds[jj][ii-1]);
+					
+				for(ii=0;ii<4;ii++) {
+					double tmp = gsl_vector_get(vecbPlStrain,ii) + positionP[ii]*elementExt->plasticStrain[tetra_I];
+					gsl_vector_set(vecbPlStrain,ii,tmp); 
+					
+					for(jj=0;jj<4;jj++) {
+						tmp = gsl_matrix_get(matA,ii,jj) + positionP[ii]*positionP[jj];
+						gsl_matrix_set(matA,ii,jj,tmp);
+					}
+				} /* end of verteces of a tet. */
+			} /* end of incident tets. */
+		} /* if within my domain */
+	} /* end of incident elements. */
+		
+	/* compute parameter vectors. */
+	{
+		int s;
+		gsl_permutation * p = gsl_permutation_alloc (4);
+     
+		gsl_linalg_LU_decomp (matA, p, &s);
+		gsl_linalg_LU_solve (matA, p, vecbPlStrain, vecaPlStrain);
+		gsl_permutation_free (p);
+	}	
+
+	/* Recover using the parameter vectors. */
+	nodeExt->plStrainSPR = gsl_vector_get(vecaPlStrain,0);
+	for(i=0;i<3;i++)
+		nodeExt->plStrainSPR += gsl_vector_get(vecaPlStrain,i+1)*(*coord)[i];
+
+	/* free gsl vectors and matrix. */
+	gsl_matrix_free( matA );
+	gsl_vector_free( vecaPlStrain );
+	gsl_vector_free( vecbPlStrain );
+
+	/* Free the element node array. */
+	FreeArray( elements );
+	
+	/* end of recovery. */
+}
+
+
+void _SnacPlastic_InterpolateNode( void* _context,
+								   unsigned nodeInd, unsigned elementInd, unsigned tetInd, 
+								   unsigned* tetNodeInds, double* weights, 
+								   Snac_Node* dstNodes )
+{
+	Snac_Context*			context = (Snac_Context*)_context;
+	Mesh*					mesh = context->mesh;
+	NodeLayout*				nLayout = mesh->layout->nodeLayout;
+	SnacPlastic_Node*		dstNodeExt = (SnacPlastic_Node*)ExtensionManager_At( context->mesh->nodeExtensionMgr, 
+																				 dstNodes, 
+																				 nodeInd );
+	Index					tetNode_i;
+
+	SnacPlastic_Node_Print( dstNodeExt );
+
+	/* Extract the element's node indices.  Note that there should always be eight of these. */
+	Node_DomainIndex*	eltNodes;
+	unsigned int nEltNodes = 8;
+	{
+		Element_GlobalIndex	gEltInd;
+
+		eltNodes = Memory_Alloc_Array( Node_DomainIndex, nEltNodes, "SnacPlastic" );
+		gEltInd = Mesh_ElementMapDomainToGlobal( mesh, elementInd );
+		nLayout->buildElementNodes( nLayout, gEltInd, eltNodes );
+	}
+
+	/* Convert global node indices to local. */
+	{
+		unsigned	eltNode_i;
+
+		for( eltNode_i = 0; eltNode_i < nEltNodes; eltNode_i++ ) {
+			eltNodes[eltNode_i] = Mesh_NodeMapGlobalToDomain( mesh, eltNodes[eltNode_i] );
+		}
+	}
+
+	/* Clear the plastic strain. */
+	dstNodeExt->plStrainSPR = 0.0;
+
+	/* Loop over each contributing node. */
+/* 	fprintf(stderr,"node=%d ",nodeInd ); */
+	for( tetNode_i = 0; tetNode_i < 4; tetNode_i++ ) {
+
+		/* Where is this contibution coming from? */
+		Snac_Node* srcNode = Snac_Node_At( context, eltNodes[tetNodeInds[tetNode_i]] );
+		SnacPlastic_Node*	srcNodeExt = ExtensionManager_Get( context->mesh->nodeExtensionMgr, 
+															   srcNode, 
+															   SnacPlastic_NodeHandle );
+
+		dstNodeExt->plStrainSPR += srcNodeExt->plStrainSPR * weights[tetNode_i];
+
+/* 		fprintf(stderr,"%d:(%d %e %e)  ",tetNode_i, eltNodes[tetNodeInds[tetNode_i]], */
+/* 				srcNodeExt->plStrainSPR, weights[tetNode_i]); */
+	}
+/* 	fprintf(stderr," %e\n", dstNodeExt->plStrainSPR); */
+
+}
+
+
+void _SnacPlastic_InterpolateElement( void* _context, 
+									  unsigned dstEltInd,
+									  unsigned dstTetInd )
+{
+	Snac_Context* 			context = (Snac_Context*)_context;
+	Snac_Element*			dstElt = Snac_Element_At( context, dstEltInd );
+	SnacPlastic_Element*	dstEltExt = ExtensionManager_Get( context->mesh->elementExtensionMgr, 
+															  dstElt,
+															  SnacPlastic_ElementHandle );
+	double				 	plasticStrain = 0.0;
+	Index 					i;
+	
+	for(i=0;i<4;i++) {
+		Snac_Node*			node = Snac_Element_Node_P( context, dstEltInd, TetraToNode[dstTetInd][i] );
+		SnacPlastic_Node*	nodeExt = ExtensionManager_Get( context->mesh->nodeExtensionMgr, 
+															node, 
+															SnacPlastic_NodeHandle );
+		plasticStrain += 0.25f*nodeExt->plStrainSPR;
+ 		fprintf(stderr,"element=%d tet=%d %d:(%d %e)\n",dstEltInd, dstTetInd, i, TetraToNode[dstTetInd][i], nodeExt->plStrainSPR);
+	}
+ 	fprintf(stderr,"\n"); 
+	dstEltExt->plasticStrain[dstTetInd] = plasticStrain;
+}

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/Remesh.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,50 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**
+** Assumptions:
+**
+** Comments:
+**
+** $Id: Remesh.h 3250 2006-10-23 06:15:18Z LukeHodkinson $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_Remesh_h__
+#define __SnacPlastic_Remesh_h__
+
+void _SnacPlastic_RecoverNode( void* context, unsigned nodeInd );
+void _SnacPlastic_InterpolateNode( void* context,
+									unsigned nodeInd, unsigned elementInd, unsigned tetInd, 
+									unsigned* tetNodeInds, double* weights, 
+									Snac_Node* dstNodes );
+void _SnacPlastic_InterpolateElement( void* _context, unsigned dstElementInd, unsigned dstTetInd );
+	
+#endif /* __SnacPlastic_Remesh_h__ */

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/makefile
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/makefile	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/makefile	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,53 @@
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+##
+## Copyright (C), 2003, 
+##	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+##	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+##	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+##
+## Authors:
+##	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+##	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+##	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+##	Luc Lavier, Research Scientist, Caltech.
+##
+## 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 the
+## Free Software Foundation; either version 2, or (at your option) any
+## later version.
+## 
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+## 
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+##
+## $Id: makefile 3049 2005-06-22 07:46:15Z AlanLo $
+##
+##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+# obtain defaults for required variables according to system and project location, and then run the build.
+ifndef PROJ_ROOT
+	PROJ_ROOT=../..
+endif
+include ${PROJ_ROOT}/Makefile.system
+
+include Makefile.def
+
+mod = ${def_mod}
+includes = ${def_inc}
+
+SRCS = ${def_srcs}
+
+HDRS = ${def_hdrs}
+
+PROJ_LIBS = ${def_libs}
+EXTERNAL_LIBS = -L${STGERMAIN_LIBDIR}  -lSnac -lStGermain 
+EXTERNAL_INCLUDES = -I${STGERMAIN_INCDIR}/StGermain -I${STGERMAIN_INCDIR} 
+
+packages = MPI XML MATH GSL
+
+include ${PROJ_ROOT}/Makefile.vmake

Added: long/3D/SNAC/trunk/Snac/plugins/plasticSPR/types.h
===================================================================
--- long/3D/SNAC/trunk/Snac/plugins/plasticSPR/types.h	                        (rev 0)
+++ long/3D/SNAC/trunk/Snac/plugins/plasticSPR/types.h	2009-11-14 19:14:52 UTC (rev 15968)
@@ -0,0 +1,52 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+**
+** Copyright (C), 2003, 
+**	Steve Quenette, 110 Victoria Street, Melbourne, Victoria, 3053, Australia.
+**	Californian Institute of Technology, 1200 East California Boulevard, Pasadena, California, 91125, USA.
+**	University of Texas, 1 University Station, Austin, Texas, 78712, USA.
+**
+** Authors:
+**	Stevan M. Quenette, Senior Software Engineer, VPAC. (steve at vpac.org)
+**	Stevan M. Quenette, Visitor in Geophysics, Caltech.
+**	Luc Lavier, Research Scientist, The University of Texas. (luc at utig.ug.utexas.edu)
+**	Luc Lavier, Research Scientist, Caltech.
+**
+** 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 the
+** Free Software Foundation; either version 2, or (at your option) any
+** later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU General Public License for more details.
+** 
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+**
+*/
+/** \file
+** Role:
+**	Plastic types.
+**
+** Assumptions:
+**	None as yet.
+**
+** Comments:
+**	None as yet.
+**
+** $Id: types.h 1677 2004-07-20 10:30:34Z SteveQuenette $
+**
+**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+
+#ifndef __SnacPlastic_types_h__
+#define __SnacPlastic_types_h__
+	
+	/* Plastic */
+	typedef struct _SnacPlastic_Node	SnacPlastic_Node;
+	typedef struct _SnacPlastic_Element	SnacPlastic_Element;
+	typedef struct _SnacPlastic_Mesh	SnacPlastic_Mesh;
+	typedef struct _SnacPlastic_Context	SnacPlastic_Context;
+	
+#endif /* __SnacPlastic_types_h__ */



More information about the CIG-COMMITS mailing list