Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 16342)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 16343)
@@ -78,4 +78,8 @@
 					./classes/Elements/ElementHook.h\
 					./classes/Elements/ElementHook.cpp\
+					./classes/Elements/Seg.h\
+					./classes/Elements/Seg.cpp\
+					./classes/Elements/SegRef.h\
+					./classes/Elements/SegRef.cpp\
 					./classes/Elements/Tria.h\
 					./classes/Elements/Tria.cpp\
Index: /issm/trunk-jpl/src/c/analyses/stressbalance_core.cpp
===================================================================
--- /issm/trunk-jpl/src/c/analyses/stressbalance_core.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/analyses/stressbalance_core.cpp	(revision 16343)
@@ -47,5 +47,5 @@
 	/*Compute slopes: */
 	if(isSIA) surfaceslope_core(femmodel);
-	if(isFS){
+	if(isFS && meshtype==Mesh3DEnum){
 		bedslope_core(femmodel);
 		femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum);
Index: /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 16343)
@@ -2242,36 +2242,7 @@
 	#endif
 
-	//Need to know the type of approximation for this element
+	/*Need to know the type of approximation for this element*/
 	if(iomodel->Data(FlowequationElementEquationEnum)){
-		if (iomodel->Data(FlowequationElementEquationEnum)[index]==SSAApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,SSAApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==HOApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,HOApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==SSAHOApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,SSAHOApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==SIAApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,SIAApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==L1L2ApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,L1L2ApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==FSApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,FSApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==SSAFSApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,SSAFSApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==HOFSApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,HOFSApproximationEnum));
-		}
-		else if (iomodel->Data(FlowequationElementEquationEnum)[index]==NoneApproximationEnum){
-			this->inputs->AddInput(new IntInput(ApproximationEnum,NoneApproximationEnum));
-		}
-		else{
-			_error_("Approximation type " << EnumToStringx(reCast<int,IssmDouble>(iomodel->Data(FlowequationElementEquationEnum)[index])) << " not supported yet");
-		}
+		this->inputs->AddInput(new IntInput(ApproximationEnum,iomodel->Data(FlowequationElementEquationEnum)[index]));
 	}
 
Index: /issm/trunk-jpl/src/c/classes/Elements/Seg.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Seg.cpp	(revision 16343)
+++ /issm/trunk-jpl/src/c/classes/Elements/Seg.cpp	(revision 16343)
@@ -0,0 +1,140 @@
+/*!\file Seg.cpp
+ * \brief: implementation of the Segment object
+ */
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include "../classes.h"
+#include "../../shared/shared.h"
+/*}}}*/
+
+/*Element macros*/
+#define NUMVERTICES 2
+/*Constructors/destructor/copy*/
+/*FUNCTION Seg::Seg(){{{*/
+Seg::Seg(){
+	this->nodes      = NULL;
+	this->vertices   = NULL;
+	this->material   = NULL;
+	this->matpar     = NULL;
+	this->inputs     = NULL;
+	this->parameters = NULL;
+	this->results    = NULL;
+}
+/*}}}*/
+/*FUNCTION Seg::Seg(int id, int sid,int index, IoModel* iomodel,int nummodels){{{*/
+Seg::Seg(int seg_id, int seg_sid, int index, IoModel* iomodel,int nummodels)
+		:SegRef(nummodels),ElementHook(nummodels,index+1,2,iomodel){
+
+			/*id: */
+			this->id  = seg_id;
+			this->sid = seg_sid;
+
+			//this->parameters: we still can't point to it, it may not even exist. Configure will handle this.
+			this->parameters = NULL;
+
+			/*intialize inputs and results: */
+			this->inputs  = new Inputs();
+			this->results = new Results();
+
+			/*initialize pointers:*/
+			this->nodes    = NULL;
+			this->vertices = NULL;
+			this->material = NULL;
+			this->matpar   = NULL;
+
+		}
+/*}}}*/
+/*FUNCTION Seg::~Seg(){{{*/
+Seg::~Seg(){
+	delete inputs;
+	delete results;
+	this->parameters=NULL;
+}
+/*}}}*/
+/*FUNCTION Seg::copy {{{*/
+Object* Seg::copy() {
+	_error_("not implemented yet");
+}
+/*}}}*/
+
+/*FUNCTION Seg::Echo{{{*/
+void Seg::Echo(void){
+	_printf_("Seg:\n");
+	_printf_("   id: " << id << "\n");
+	if(nodes){
+		nodes[0]->Echo();
+		nodes[1]->Echo();
+	}
+	else _printf_("nodes = NULL\n");
+
+	if (material) material->Echo();
+	else _printf_("material = NULL\n");
+
+	if (matpar) matpar->Echo();
+	else _printf_("matpar = NULL\n");
+
+	_printf_("   parameters\n");
+	if (parameters) parameters->Echo();
+	else _printf_("parameters = NULL\n");
+
+	_printf_("   inputs\n");
+	if (inputs) inputs->Echo();
+	else _printf_("inputs=NULL\n");
+
+	if (results) results->Echo();
+	else _printf_("results=NULL\n");
+}
+/*}}}*/
+/*FUNCTION Seg::DeepEcho{{{*/
+void Seg::DeepEcho(void){
+
+	_printf_("Seg:\n");
+	_printf_("   id: " << id << "\n");
+	if(nodes){
+		nodes[0]->DeepEcho();
+		nodes[1]->DeepEcho();
+	}
+	else _printf_("nodes = NULL\n");
+
+	if (material) material->DeepEcho();
+	else _printf_("material = NULL\n");
+
+	if (matpar) matpar->DeepEcho();
+	else _printf_("matpar = NULL\n");
+
+	_printf_("   parameters\n");
+	if (parameters) parameters->DeepEcho();
+	else _printf_("parameters = NULL\n");
+
+	_printf_("   inputs\n");
+	if (inputs) inputs->DeepEcho();
+	else _printf_("inputs=NULL\n");
+
+	if (results) results->DeepEcho();
+	else _printf_("results=NULL\n");
+
+	return;
+}
+/*}}}*/
+/*FUNCTION Seg::ObjectEnum{{{*/
+int Seg::ObjectEnum(void){
+
+	return SegEnum;
+
+}
+/*}}}*/
+/*FUNCTION Seg::Id {{{*/
+int    Seg::Id(){
+
+	return id;
+
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Seg.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 16343)
+++ /issm/trunk-jpl/src/c/classes/Elements/Seg.h	(revision 16343)
@@ -0,0 +1,176 @@
+/*! \file Seg.h 
+ *  \brief: header file for seg object
+ */
+
+#ifndef _SEG_H_
+#define _SEG_H_
+
+/*Headers:*/
+/*{{{*/
+#include "./Element.h"
+#include "./ElementHook.h"
+#include "./SegRef.h"
+class Parameters;
+class Inputs;
+class IoModel;
+class Results;
+class Node;
+class Material;
+class Matpar;
+class ElementMatrix;
+class ElementVector;
+class Vertex;
+
+#include "../../shared/Exceptions/exceptions.h"
+#include "../../shared/Enum/Enum.h"
+/*}}}*/
+
+class Seg: public Element,public ElementHook,public SegRef{
+
+	public:
+
+		int          id;
+		int          sid;
+
+		Node       **nodes;                       // nodes
+		Vertex     **vertices;                    // 3 vertices
+		Material    *material;                    // 1 material ice
+		Matpar      *matpar;                      // 1 material parameter
+
+		Parameters  *parameters;                  //pointer to solution parameters
+		Inputs      *inputs;
+		Results     *results;
+
+		/*Seg constructors, destructors {{{*/
+		Seg();
+		Seg(int seg_id,int seg_sid,int i, IoModel* iomodel,int nummodels);
+		~Seg();
+		/*}}}*/
+		/*Object virtual functions definitions:{{{ */
+		void    Echo();
+		void    DeepEcho();
+		int     Id();
+		int     ObjectEnum();
+		Object *copy();
+		/*}}}*/
+		/*Update virtual functions resolution: {{{*/
+		void  InputUpdateFromSolution(IssmDouble* solutiong){_error_("not implemented yet");};
+		void  InputUpdateFromVector(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
+#ifdef _HAVE_DAKOTA_
+		void  InputUpdateFromVectorDakota(IssmDouble* vector, int name, int type){_error_("not implemented yet");};
+		void  InputUpdateFromMatrixDakota(IssmDouble* matrix, int nows, int ncols, int name, int type){_error_("not implemented yet");};
+#endif
+		void  InputUpdateFromConstant(IssmDouble constant, int name){_error_("not implemented yet");};
+		void  InputUpdateFromConstant(int constant, int name){_error_("not implemented yet");};
+		void  InputUpdateFromConstant(bool constant, int name){_error_("not implemented yet");};
+		void  InputUpdateFromIoModel(int index, IoModel* iomodel){_error_("not implemented yet");};
+		/*}}}*/
+		/*Element virtual functions definitions: {{{*/
+		void        ComputeBasalStress(Vector<IssmDouble>* sigma_b){_error_("not implemented yet");};
+		void        ComputeStrainRate(Vector<IssmDouble>* eps){_error_("not implemented yet");};
+		void        ComputeStressTensor(){_error_("not implemented yet");};
+		void        Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters){_error_("not implemented yet");};
+		void        SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters){_error_("not implemented yet");};
+		void        SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum){_error_("not implemented yet");};
+		void        CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs){_error_("not implemented yet");};
+		void        CreateDVector(Vector<IssmDouble>* df){_error_("not implemented yet");};
+		void        CreatePVector(Vector<IssmDouble>* pf){_error_("not implemented yet");};
+		void        CreateJacobianMatrix(Matrix<IssmDouble>* Jff){_error_("not implemented yet");};
+		void        Delta18oParameterization(void){_error_("not implemented yet");};
+		int         GetNodeIndex(Node* node){_error_("not implemented yet");};
+		void        GetNodesSidList(int* sidlist){_error_("not implemented yet");};
+		void        GetNodesLidList(int* lidlist){_error_("not implemented yet");};
+		int         GetNumberOfNodes(void){_error_("not implemented yet");};
+		int         Sid(){_error_("not implemented yet");};
+		bool        IsOnBed(){_error_("not implemented yet");};
+		bool        IsFloating(){_error_("not implemented yet");};
+		bool        IsNodeOnShelfFromFlags(IssmDouble* flags){_error_("not implemented yet");};
+		bool        NoIceInElement(){_error_("not implemented yet");};
+		void        GetSolutionFromInputs(Vector<IssmDouble>* solution){_error_("not implemented yet");};
+		void        GetVectorFromInputs(Vector<IssmDouble>* vector, int name_enum){_error_("not implemented yet");};
+		void        GetVectorFromResults(Vector<IssmDouble>* vector,int offset,int enum_in,int interp){_error_("not implemented yet");};
+		void        InputCreate(IssmDouble* vector,IoModel* iomodel,int M,int N,int vector_type,int vector_enum,int code){_error_("not implemented yet");};
+		void        InputDepthAverageAtBase(int enum_type,int average_enum_type,int object_enum=MeshElementsEnum){_error_("not implemented yet");};
+		void        InputDuplicate(int original_enum,int new_enum){_error_("not implemented yet");};
+		void        InputScale(int enum_type,IssmDouble scale_factor){_error_("not implemented yet");};
+		void        InputToResult(int enum_type,int step,IssmDouble time){_error_("not implemented yet");};
+		void        DeleteResults(void){_error_("not implemented yet");};
+		void        MaterialUpdateFromTemperature(void){_error_("not implemented yet");};
+		int         NodalValue(IssmDouble* pvalue, int index, int natureofdataenum){_error_("not implemented yet");};
+		void        PositiveDegreeDay(IssmDouble* pdds,IssmDouble* pds,IssmDouble signorm){_error_("not implemented yet");};
+		void        RequestedOutput(int output_enum,int step,IssmDouble time){_error_("not implemented yet");};
+		void        ListResultsInfo(int** results_enums,int** results_size,IssmDouble** results_times,int** results_steps,int* num_results){_error_("not implemented yet");};
+		void        PatchFill(int* pcount, Patch* patch){_error_("not implemented yet");};
+		void        PatchSize(int* pnumrows, int* pnumvertices,int* pnumnodes){_error_("not implemented yet");};
+		void        ResetCoordinateSystem(void){_error_("not implemented yet");};
+		void	      SmbGradients(){_error_("not implemented yet");};
+		IssmDouble  SurfaceArea(void){_error_("not implemented yet");};
+		void        Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement){_error_("not implemented yet");};
+		IssmDouble  TimeAdapt(){_error_("not implemented yet");};
+
+#ifdef _HAVE_RESPONSES_
+		void       AverageOntoPartition(Vector<IssmDouble>* partition_contributions,Vector<IssmDouble>* partition_areas,IssmDouble* vertex_response,IssmDouble* qmu_part){_error_("not implemented yet");};
+		IssmDouble IceVolume(void){_error_("not implemented yet");};
+		IssmDouble IceVolumeAboveFloatation(void){_error_("not implemented yet");};
+		IssmDouble TotalSmb(void){_error_("not implemented yet");};
+		void       MinVel(IssmDouble* pminvel){_error_("not implemented yet");};
+		void       MinVx(IssmDouble* pminvx){_error_("not implemented yet");};
+		void       MinVy(IssmDouble* pminvy){_error_("not implemented yet");};
+		void       MinVz(IssmDouble* pminvz){_error_("not implemented yet");};
+		IssmDouble MassFlux(IssmDouble* segment){_error_("not implemented yet");};
+		void       MaxAbsVx(IssmDouble* pmaxabsvx){_error_("not implemented yet");};
+		void       MaxAbsVy(IssmDouble* pmaxabsvy){_error_("not implemented yet");};
+		void       MaxAbsVz(IssmDouble* pmaxabsvz){_error_("not implemented yet");};
+		void       ElementResponse(IssmDouble* presponse,int response_enum){_error_("not implemented yet");};
+		void       MaxVel(IssmDouble* pmaxvel){_error_("not implemented yet");};
+		void       MaxVx(IssmDouble* pmaxvx){_error_("not implemented yet");};
+		void       MaxVy(IssmDouble* pmaxvy){_error_("not implemented yet");};
+		void       MaxVz(IssmDouble* pmaxvz){_error_("not implemented yet");};
+#endif
+
+#ifdef _HAVE_GIA_
+		void   GiaDeflection(Vector<IssmDouble>* wg,Vector<IssmDouble>* dwgdt,IssmDouble* x,IssmDouble* y){_error_("not implemented yet");};
+#endif
+
+#ifdef _HAVE_CONTROL_
+		IssmDouble DragCoefficientAbsGradient(void){_error_("not implemented yet");};
+		void       GradientIndexing(int* indexing,int control_index){_error_("not implemented yet");};
+		void       Gradj(Vector<IssmDouble>* gradient,int control_type,int control_index){_error_("not implemented yet");};
+		void       GradjBGradient(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjDGradient(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjBSSA(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjDSSA(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjDragSSA(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjDragFS(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjDragGradient(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjDhDtBalancedthickness(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjVxBalancedthickness(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjVyBalancedthickness(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GradjThicknessBalancethicknessSoft(Vector<IssmDouble>* gradient,int control_index){_error_("not implemented yet");};
+		void       GetVectorFromControlInputs(Vector<IssmDouble>* gradient,int control_enum,int control_index,const char* data){_error_("not implemented yet");};
+		void       SetControlInputsFromVector(IssmDouble* vector,int control_enum,int control_index){_error_("not implemented yet");};
+		void       ControlInputGetGradient(Vector<IssmDouble>* gradient,int enum_type,int control_index){_error_("not implemented yet");};
+		void       ControlInputScaleGradient(int enum_type,IssmDouble scale){_error_("not implemented yet");};
+		void       ControlInputSetGradient(IssmDouble* gradient,int enum_type,int control_index){_error_("not implemented yet");};
+		IssmDouble RheologyBbarAbsGradient(void){_error_("not implemented yet");};
+		IssmDouble ThicknessAbsMisfit(void){_error_("not implemented yet");};
+		IssmDouble SurfaceAbsVelMisfit(void){_error_("not implemented yet");};
+		IssmDouble ThicknessAbsGradient(void){_error_("not implemented yet");};
+		IssmDouble ThicknessAlongGradient(void){_error_("not implemented yet");};
+		IssmDouble ThicknessAcrossGradient(void){_error_("not implemented yet");};
+		IssmDouble BalancethicknessMisfit(void){_error_("not implemented yet");};
+		IssmDouble SurfaceRelVelMisfit(void){_error_("not implemented yet");};
+		IssmDouble SurfaceLogVelMisfit(void){_error_("not implemented yet");};
+		IssmDouble SurfaceLogVxVyMisfit(void){_error_("not implemented yet");};
+		IssmDouble SurfaceAverageVelMisfit(void){_error_("not implemented yet");};
+		void       InputControlUpdate(IssmDouble scalar,bool save_parameter){_error_("not implemented yet");};
+#endif
+
+#ifdef _HAVE_GROUNDINGLINE_
+		void   PotentialUngrounding(Vector<IssmDouble>* potential_sheet_ungrounding){_error_("not implemented yet");};
+		void   MigrateGroundingLine(IssmDouble* sheet_ungrounding){_error_("not implemented yet");};
+		int    UpdatePotentialUngrounding(IssmDouble* vertices_potentially_ungrounding,Vector<IssmDouble>* vec_nodes_on_iceshelf,IssmDouble* nodes_on_iceshelf){_error_("not implemented yet");};
+#endif
+		/*}}}*/
+};
+#endif  /* _SEG_H */
Index: /issm/trunk-jpl/src/c/classes/Elements/SegRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/SegRef.cpp	(revision 16343)
+++ /issm/trunk-jpl/src/c/classes/Elements/SegRef.cpp	(revision 16343)
@@ -0,0 +1,50 @@
+/*!\file SegRef.c
+ * \brief: implementation of the SegRef object
+ */
+
+/*Headers:*/
+/*{{{*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
+
+#include "../classes.h"
+#include "../../shared/shared.h"
+/*}}}*/
+
+/*Element macros*/
+#define NUMNODESP1  2
+
+/*Object constructors and destructor*/
+/*FUNCTION SegRef::SegRef(){{{*/
+SegRef::SegRef(){
+	this->element_type_list=NULL;
+}
+/*}}}*/
+/*FUNCTION SegRef::SegRef(int* types,int nummodels){{{*/
+SegRef::SegRef(const int nummodels){
+
+	/*Only allocate pointer*/
+	element_type_list=xNew<int>(nummodels);
+
+}
+/*}}}*/
+/*FUNCTION SegRef::~SegRef(){{{*/
+SegRef::~SegRef(){
+	xDelete<int>(element_type_list);
+}
+/*}}}*/
+
+/*Management*/
+/*FUNCTION SegRef::SetElementType{{{*/
+void SegRef::SetElementType(int type,int type_counter){
+
+	/*initialize element type*/
+	this->element_type_list[type_counter]=type;
+}
+/*}}}*/
+
+/*Reference Element numerics*/
+
Index: /issm/trunk-jpl/src/c/classes/Elements/SegRef.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/SegRef.h	(revision 16343)
+++ /issm/trunk-jpl/src/c/classes/Elements/SegRef.h	(revision 16343)
@@ -0,0 +1,25 @@
+
+/*!\file:  SegRef.h
+ * \brief abstract class for handling Seg oriented routines, like nodal functions, 
+ * strain rate generation, etc ...
+ */ 
+
+#ifndef _SEGREF_H_
+#define _SEGREF_H_
+
+class GaussSeg;
+
+class SegRef{
+
+	public: 
+		int* element_type_list;
+		int  element_type;
+
+		SegRef();
+		SegRef(const int nummodels);
+		~SegRef();
+
+		/*Management*/
+		void SetElementType(int type,int type_counter);
+};
+#endif
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 16343)
@@ -833,4 +833,53 @@
 }
 /*}}}*/
+/*FUNCTION Tria::GetDofListVelocity{{{*/
+void  Tria::GetDofListVelocity(int** pdoflist,int setenum){
+
+	/*Fetch number of nodes and dof for this finite element*/
+	int numnodes = this->NumberofNodesVelocity();
+
+	/*First, figure out size of doflist and create it: */
+	int numberofdofs=0;
+	for(int i=0;i<numnodes;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(FSvelocityEnum,setenum);
+
+	/*Allocate output*/
+	int* doflist=xNew<int>(numberofdofs);
+
+	/*Populate: */
+	int count=0;
+	for(int i=0;i<numnodes;i++){
+		nodes[i]->GetDofList(doflist+count,FSvelocityEnum,setenum);
+		count+=nodes[i]->GetNumberOfDofs(FSvelocityEnum,setenum);
+	}
+
+	/*Assign output pointers:*/
+	*pdoflist=doflist;
+}
+/*}}}*/
+/*FUNCTION Tria::GetDofListPressure{{{*/
+void  Tria::GetDofListPressure(int** pdoflist,int setenum){
+
+	/*Fetch number of nodes and dof for this finite element*/
+	int vnumnodes = this->NumberofNodesVelocity();
+	int pnumnodes = this->NumberofNodesPressure();
+
+	/*First, figure out size of doflist and create it: */
+	int numberofdofs=0;
+	for(int i=vnumnodes;i<vnumnodes+pnumnodes;i++) numberofdofs+=nodes[i]->GetNumberOfDofs(FSApproximationEnum,setenum);
+
+	/*Allocate output*/
+	int* doflist=xNew<int>(numberofdofs);
+
+	/*Populate: */
+	int count=0;
+	for(int i=vnumnodes;i<vnumnodes+pnumnodes;i++){
+		nodes[i]->GetDofList(doflist+count,FSApproximationEnum,setenum);
+		count+=nodes[i]->GetNumberOfDofs(FSApproximationEnum,setenum);
+	}
+
+	/*Assign output pointers:*/
+	*pdoflist=doflist;
+}
+/*}}}*/
 /*FUNCTION Tria::GetElementType {{{*/
 int Tria::GetElementType(){
@@ -1304,5 +1353,15 @@
 	#ifdef _HAVE_STRESSBALANCE_
 	case StressbalanceAnalysisEnum:
-		GetSolutionFromInputsStressbalanceHoriz(solution);
+		int approximation;
+		inputs->GetInputValue(&approximation,ApproximationEnum);
+		if(approximation==FSApproximationEnum || approximation==NoneApproximationEnum){
+			GetSolutionFromInputsStressbalanceFS(solution);
+		}
+		else if (approximation==SSAApproximationEnum){
+			GetSolutionFromInputsStressbalanceHoriz(solution);
+		}
+		else{
+			_error_("approximation not supported yet");
+		}
 		break;
 	case StressbalanceSIAAnalysisEnum:
@@ -1532,4 +1591,10 @@
 		tria_vertex_ids[i]=reCast<int>(iomodel->elements[3*index+i]); //ids for vertices are in the elements array from Matlab
 	}
+
+	/*Need to know the type of approximation for this element*/
+	if(iomodel->Data(FlowequationElementEquationEnum)){
+		this->inputs->AddInput(new IntInput(ApproximationEnum,iomodel->Data(FlowequationElementEquationEnum)[index]));
+	}
+
 
 	/*Control Inputs*/
@@ -1950,4 +2015,5 @@
 				name==VxEnum ||
 				name==VyEnum ||
+				name==PressureEnum ||
 				name==InversionVxObsEnum ||
 				name==InversionVyObsEnum ||
@@ -2459,4 +2525,41 @@
 			tria_node_ids[5]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[3*index+2]+1;
 			break;
+		case P1P1Enum: case P1P1GLSEnum:
+			numnodes        = 6;
+			tria_node_ids   = xNew<int>(numnodes);
+			tria_node_ids[0]=iomodel->nodecounter+iomodel->elements[3*index+0];
+			tria_node_ids[1]=iomodel->nodecounter+iomodel->elements[3*index+1];
+			tria_node_ids[2]=iomodel->nodecounter+iomodel->elements[3*index+2];
+
+			tria_node_ids[3]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elements[3*index+0];
+			tria_node_ids[4]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elements[3*index+1];
+			tria_node_ids[5]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elements[3*index+2];
+			break;
+		case MINIEnum: case MINIcondensedEnum:
+			numnodes       = 7;
+			tria_node_ids  = xNew<int>(numnodes);
+			tria_node_ids[0]=iomodel->nodecounter+iomodel->elements[3*index+0];
+			tria_node_ids[1]=iomodel->nodecounter+iomodel->elements[3*index+1];
+			tria_node_ids[2]=iomodel->nodecounter+iomodel->elements[3*index+2];
+			tria_node_ids[3]=iomodel->nodecounter+iomodel->numberofvertices+index+1;
+
+			tria_node_ids[4]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+iomodel->elements[3*index+0];
+			tria_node_ids[5]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+iomodel->elements[3*index+1];
+			tria_node_ids[6]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofelements+iomodel->elements[3*index+2];
+			break;
+		case TaylorHoodEnum:
+			numnodes        = 9;
+			tria_node_ids   = xNew<int>(numnodes);
+			tria_node_ids[0]=iomodel->nodecounter+iomodel->elements[3*index+0];
+			tria_node_ids[1]=iomodel->nodecounter+iomodel->elements[3*index+1];
+			tria_node_ids[2]=iomodel->nodecounter+iomodel->elements[3*index+2];
+			tria_node_ids[3]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[3*index+0]+1;
+			tria_node_ids[4]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[3*index+1]+1;
+			tria_node_ids[5]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->elementtoedgeconnectivity[3*index+2]+1;
+
+			tria_node_ids[6]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->elements[3*index+0];
+			tria_node_ids[7]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->elements[3*index+1];
+			tria_node_ids[8]=iomodel->nodecounter+iomodel->numberofvertices+iomodel->numberofedges+iomodel->elements[3*index+2];
+			break;
 		default:
 			_error_("Finite element "<<EnumToStringx(finiteelement_type)<<" not supported yet");
@@ -3386,4 +3489,59 @@
 	delete gauss;
 	return Ke;
+}
+/*}}}*/
+/*FUNCTION Tria::GetSolutionFromInputsStressbalanceFS{{{*/
+void  Tria::GetSolutionFromInputsStressbalanceFS(Vector<IssmDouble>* solution){
+
+	int*         vdoflist=NULL;
+	int*         pdoflist=NULL;
+	IssmDouble   vx,vy,p;
+	IssmDouble   FSreconditioning;
+	GaussTria   *gauss;
+
+	/*Fetch number of nodes and dof for this finite element*/
+	int vnumnodes = this->NumberofNodesVelocity();
+	int pnumnodes = this->NumberofNodesPressure();
+	int vnumdof   = vnumnodes*NDOF2;
+	int pnumdof   = pnumnodes*NDOF1;
+
+	/*Initialize values*/
+	IssmDouble* vvalues = xNew<IssmDouble>(vnumdof);
+	IssmDouble* pvalues = xNew<IssmDouble>(pnumdof);
+
+	/*Get dof list: */
+	GetDofListVelocity(&vdoflist,GsetEnum);
+	GetDofListPressure(&pdoflist,GsetEnum);
+	Input* vx_input=inputs->GetInput(VxEnum);       _assert_(vx_input);
+	Input* vy_input=inputs->GetInput(VyEnum);       _assert_(vy_input);
+	Input* p_input =inputs->GetInput(PressureEnum); _assert_(p_input);
+
+	this->parameters->FindParam(&FSreconditioning,StressbalanceFSreconditioningEnum);
+
+	/*Ok, we have vx vy vz in values, fill in vx vy vz arrays: */
+	gauss = new GaussTria();
+	for(int i=0;i<vnumnodes;i++){
+		gauss->GaussNode(this->VelocityInterpolation(),i);
+		vx_input->GetInputValue(&vx,gauss);
+		vy_input->GetInputValue(&vy,gauss);
+		vvalues[i*NDOF2+0]=vx;
+		vvalues[i*NDOF2+1]=vy;
+	}
+	for(int i=0;i<pnumnodes;i++){
+		gauss->GaussNode(this->PressureInterpolation(),i);
+		p_input->GetInputValue(&p ,gauss);
+		pvalues[i]=p/FSreconditioning;
+	}
+
+	/*Add value to global vector*/
+	solution->SetValues(vnumdof,vdoflist,vvalues,INS_VAL);
+	solution->SetValues(pnumdof,pdoflist,pvalues,INS_VAL);
+
+	/*Free ressources:*/
+	delete gauss;
+	xDelete<int>(pdoflist);
+	xDelete<int>(vdoflist);
+	xDelete<IssmDouble>(pvalues);
+	xDelete<IssmDouble>(vvalues);
 }
 /*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/Tria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 16342)
+++ /issm/trunk-jpl/src/c/classes/Elements/Tria.h	(revision 16343)
@@ -205,4 +205,6 @@
 		int            GetElementType(void);
 		void	         GetDofList(int** pdoflist,int approximation_enum,int setenum);
+		void	         GetDofListVelocity(int** pdoflist,int setenum);
+		void	         GetDofListPressure(int** pdoflist,int setenum);
 		void	         GetVertexPidList(int* doflist);
 		void           GetVertexSidList(int* sidlist);
@@ -236,4 +238,5 @@
 		ElementVector* CreatePVectorStressbalanceSIA(void);
 		ElementMatrix* CreateJacobianStressbalanceSSA(void);
+		void	  GetSolutionFromInputsStressbalanceFS(Vector<IssmDouble>* solution);
 		void	  GetSolutionFromInputsStressbalanceHoriz(Vector<IssmDouble>* solution);
 		void	  GetSolutionFromInputsStressbalanceSIA(Vector<IssmDouble>* solution);
Index: /issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp	(revision 16343)
@@ -43,6 +43,4 @@
 /*FUNCTION TriaRef::SetElementType{{{*/
 void TriaRef::SetElementType(int type,int type_counter){
-
-	_assert_(type==P1Enum || type==P1DGEnum || type==P1bubbleEnum || type==P1bubblecondensedEnum || type==P2Enum);
 
 	/*initialize element type*/
@@ -653,4 +651,9 @@
 		case P1bubblecondensedEnum: return NUMNODESP1b;
 		case P2Enum:                return NUMNODESP2;
+		case P1P1Enum:              return NUMNODESP1*2;
+		case P1P1GLSEnum:           return NUMNODESP1*2;
+		case MINIcondensedEnum:     return NUMNODESP1b+NUMNODESP1;
+		case MINIEnum:              return NUMNODESP1b+NUMNODESP1;
+		case TaylorHoodEnum:        return NUMNODESP2+NUMNODESP1;
 		default: _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
 	}
@@ -659,2 +662,62 @@
 }
 /*}}}*/
+/*FUNCTION TriaRef::NumberofNodesPressure{{{*/
+int TriaRef::NumberofNodesPressure(void){
+
+	switch(this->element_type){
+		case P1P1Enum:          return NUMNODESP1;
+		case P1P1GLSEnum:       return NUMNODESP1;
+		case MINIcondensedEnum: return NUMNODESP1;
+		case MINIEnum:          return NUMNODESP1;
+		case TaylorHoodEnum:    return NUMNODESP1;
+		default: _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
+	}
+
+	return -1;
+}
+/*}}}*/
+/*FUNCTION TriaRef::NumberofNodesVelocity{{{*/
+int TriaRef::NumberofNodesVelocity(void){
+
+	switch(this->element_type){
+		case P1P1Enum:          return NUMNODESP1;
+		case P1P1GLSEnum:       return NUMNODESP1;
+		case MINIcondensedEnum: return NUMNODESP1b;
+		case MINIEnum:          return NUMNODESP1b;
+		case TaylorHoodEnum:    return NUMNODESP2;
+		default:       _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
+	}
+
+	return -1;
+}
+/*}}}*/
+/*FUNCTION TriaRef::VelocityInterpolation{{{*/
+int TriaRef::VelocityInterpolation(void){
+
+	switch(this->element_type){
+		case P1P1Enum:          return P1Enum;
+		case P1P1GLSEnum:       return P1Enum;
+		case MINIcondensedEnum: return P1bubbleEnum;
+		case MINIEnum:          return P1bubbleEnum;
+		case TaylorHoodEnum:    return P2Enum;
+		default:       _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
+	}
+
+	return -1;
+}
+/*}}}*/
+/*FUNCTION TriaRef::PressureInterpolation{{{*/
+int TriaRef::PressureInterpolation(void){
+
+	switch(this->element_type){
+		case P1P1Enum:          return P1Enum;
+		case P1P1GLSEnum:       return P1Enum;
+		case MINIcondensedEnum: return P1Enum;
+		case MINIEnum:          return P1Enum;
+		case TaylorHoodEnum:    return P1Enum;
+		default:       _error_("Element type "<<EnumToStringx(this->element_type)<<" not supported yet");
+	}
+
+	return -1;
+}
+/*}}}*/
Index: /issm/trunk-jpl/src/c/classes/Elements/TriaRef.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/Elements/TriaRef.h	(revision 16342)
+++ /issm/trunk-jpl/src/c/classes/Elements/TriaRef.h	(revision 16343)
@@ -45,4 +45,8 @@
 
 		int  NumberofNodes(void);
+		int  NumberofNodesVelocity(void);
+		int  NumberofNodesPressure(void);
+		int  VelocityInterpolation(void);
+		int  PressureInterpolation(void);
 };
 #endif
Index: /issm/trunk-jpl/src/c/classes/Node.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/Node.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/classes/Node.cpp	(revision 16343)
@@ -39,5 +39,5 @@
 	/*indexing:*/
 	this->indexingupdate = true;
-	DistributeNumDofs(&this->indexing,analysis_type,in_approximation); //number of dofs per node
+	DistributeNumDofs(&this->indexing,analysis_type,in_approximation,iomodel->meshtype); //number of dofs per node
 
 	if(analysis_type==StressbalanceAnalysisEnum)
@@ -920,5 +920,4 @@
 			case PressureEnum: numdofs+=1; break;
 			case XYEnum:       numdofs+=2; break;
-			case XZEnum:       numdofs+=2; break;
 			case XYZEnum:      numdofs+=3; break;
 			default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
@@ -971,5 +970,4 @@
 			case PressureEnum: numdofs+=1; break;
 			case XYEnum:       numdofs+=2; break;
-			case XZEnum:       numdofs+=2; break;
 			case XYZEnum:      numdofs+=3; break;
 			default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
@@ -1021,5 +1019,4 @@
 			case PressureEnum: numdofs+=1; break;
 			case XYEnum:       numdofs+=2; break;
-			case XZEnum:       numdofs+=2; break;
 			case XYZEnum:      numdofs+=3; break;
 			default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
@@ -1070,5 +1067,4 @@
 			case PressureEnum: numdofs+=1; break;
 			case XYEnum:       numdofs+=2; break;
-			case XZEnum:       numdofs+=2; break;
 			case XYZEnum:      numdofs+=3; break;
 			default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
@@ -1110,5 +1106,4 @@
 			case PressureEnum: numdofs+=1; break;
 			case XYEnum:       numdofs+=2; break;
-			case XZEnum:       numdofs+=2; break;
 			case XYZEnum:      numdofs+=3; break;
 			default: _error_("Coordinate system " << EnumToStringx(cs_array[i]) << " not supported yet");
@@ -1147,13 +1142,4 @@
 				counter+=2;
 				break;
-			case XZEnum:
-				/*We remove the y component, we need to renormalize x and z: x=[x1 0 x2] y=[-x2 0 x1]*/
-				norm = sqrt( coord_system[0][0]*coord_system[0][0] + coord_system[2][0]*coord_system[2][0]); _assert_(norm>1.e-4);
-				transform[(numdofs)*(counter+0) + counter+0] =   coord_system[0][0]/norm;
-				transform[(numdofs)*(counter+0) + counter+2] = - coord_system[2][0]/norm;
-				transform[(numdofs)*(counter+1) + counter+0] =   coord_system[2][0]/norm;
-				transform[(numdofs)*(counter+1) + counter+2] =   coord_system[0][0]/norm;
-				counter+=2;
-				break;
 			case XYZEnum:
 				/*The 3 coordinates are changed (x,y,z)*/
Index: /issm/trunk-jpl/src/c/classes/classes.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/classes.h	(revision 16342)
+++ /issm/trunk-jpl/src/c/classes/classes.h	(revision 16343)
@@ -39,4 +39,6 @@
 #include "./Elements/Penta.h"
 #include "./Elements/PentaRef.h"
+#include "./Elements/Seg.h"
+#include "./Elements/SegRef.h"
 #include "./Elements/Tria.h"
 #include "./Elements/TriaRef.h"
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/DistributeNumDofs.cpp	(revision 16343)
@@ -6,5 +6,5 @@
 #include "../../classes/classes.h"
 
-void DistributeNumDofs(DofIndexing* index,int analysis_type,int node_type){
+void DistributeNumDofs(DofIndexing* index,int analysis_type,int node_type,int mesh_type){
 
 	/*For now, we distribute by analysis_type, later, we will distribute using the analysis_type,
@@ -31,5 +31,13 @@
 					break;
 				case FSvelocityEnum:
-					numdofs=3;
+					if(mesh_type==Mesh3DEnum){
+						numdofs=3;
+					}
+					else if(mesh_type==Mesh2DverticalEnum){
+						numdofs=2;
+					}
+					else{
+						_error_("mesh type not supported yet");
+					}
 					break;
 				case FSpressureEnum:
@@ -37,5 +45,13 @@
 					break;
 				case NoneApproximationEnum:
-					numdofs=4;
+					if(mesh_type==Mesh3DEnum){
+						numdofs=4;
+					}
+					else if(mesh_type==Mesh2DverticalEnum){
+						numdofs=3;
+					}
+					else{
+						_error_("mesh type not supported yet");
+					}
 					break;
 				case SSAHOApproximationEnum:
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 16342)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 16343)
@@ -158,5 +158,5 @@
 
 /*Distribution of dofs: */
-void DistributeNumDofs(DofIndexing* index,int analysis_type,int node_type);
+void DistributeNumDofs(DofIndexing* index,int analysis_type,int node_type,int mesh_type);
 
 #endif
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/Stressbalance/CreateConstraintsStressbalance.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/Stressbalance/CreateConstraintsStressbalance.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/Stressbalance/CreateConstraintsStressbalance.cpp	(revision 16343)
@@ -88,15 +88,20 @@
 		}
 
-		IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,1);
-		IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvyEnum,StressbalanceAnalysisEnum,finiteelement,2);
-
 		if(isFS){
 
 			/*Constraint at the bedrock interface (v.n = vz = 0) (Coordinates will be updated according to the bed slope)*/
-			iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvzEnum);
 			iomodel->FetchData(&vertices_type,NULL,NULL,FlowequationVertexEquationEnum);
 			iomodel->FetchData(&nodeonFS,NULL,NULL,FlowequationBorderFSEnum);
 			iomodel->FetchData(&nodeonbed,NULL,NULL,MeshVertexonbedEnum);
 			iomodel->FetchData(&groundedice_ls,NULL,NULL,MaskGroundediceLevelsetEnum);
+			if(iomodel->meshtype==Mesh3DEnum){
+				iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvzEnum);
+			}
+			else if (iomodel->meshtype==Mesh2DverticalEnum){
+				iomodel->FetchData(&spcvz,&Mz,&Nz,StressbalanceSpcvyEnum);
+			}
+			else{
+				_error_("not supported yet");
+			}
 			for(i=0;i<iomodel->numberofvertices;i++){
 				if(iomodel->my_vertices[i]){
@@ -111,6 +116,18 @@
 				}
 			}
-			IoModelToConstraintsx(constraints,iomodel,spcvz,Mz,Nz,StressbalanceAnalysisEnum,finiteelement,3);
-			iomodel->DeleteData(spcvz,StressbalanceSpcvzEnum);
+			if(iomodel->meshtype==Mesh3DEnum){
+				IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,1);
+				IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvyEnum,StressbalanceAnalysisEnum,finiteelement,2);
+				IoModelToConstraintsx(constraints,iomodel,spcvz,Mz,Nz,StressbalanceAnalysisEnum,finiteelement,3);
+				iomodel->DeleteData(spcvz,StressbalanceSpcvzEnum);
+			}
+			else if (iomodel->meshtype==Mesh2DverticalEnum){
+				IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,1);
+				IoModelToConstraintsx(constraints,iomodel,spcvz,Mz,Nz,StressbalanceAnalysisEnum,finiteelement,2);
+				iomodel->DeleteData(spcvz,StressbalanceSpcvyEnum);
+			}
+			else{
+				_error_("not supported yet");
+			}
 			iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum);
 			iomodel->DeleteData(nodeonFS,FlowequationBorderFSEnum);
@@ -151,4 +168,8 @@
 			iomodel->DeleteData(z,MeshZEnum);
 		}
+		else{
+			IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvxEnum,StressbalanceAnalysisEnum,finiteelement,1);
+			IoModelToConstraintsx(constraints,iomodel,StressbalanceSpcvyEnum,StressbalanceAnalysisEnum,finiteelement,2);
+		}
 
 		*pconstraints=constraints;
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/Stressbalance/UpdateElementsStressbalance.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/Stressbalance/UpdateElementsStressbalance.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/Stressbalance/UpdateElementsStressbalance.cpp	(revision 16343)
@@ -112,8 +112,8 @@
 		iomodel->FetchDataToInput(elements,VzEnum,0.);
 		if(dakota_analysis)elements->InputDuplicate(VzEnum,QmuVzEnum);
-		if(isFS){
-			iomodel->FetchDataToInput(elements,PressureEnum,0.);
-			if(dakota_analysis)elements->InputDuplicate(PressureEnum,QmuPressureEnum);
-		}
+	}
+	if(isFS){
+		iomodel->FetchDataToInput(elements,PressureEnum,0.);
+		if(dakota_analysis)elements->InputDuplicate(PressureEnum,QmuPressureEnum);
 	}
 
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/CreateConstraintsStressbalanceVertical.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/CreateConstraintsStressbalanceVertical.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/CreateConstraintsStressbalanceVertical.cpp	(revision 16343)
@@ -20,6 +20,6 @@
 	Constraints* constraints=*pconstraints;
 
-	/*return if 2d mesh*/
-	if(iomodel->meshtype==Mesh2DhorizontalEnum) return;
+	/*return if not 3d mesh*/
+	if(iomodel->meshtype!=Mesh3DEnum) return;
 
 	/*Fetch data: */
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/CreateNodesStressbalanceVertical.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/CreateNodesStressbalanceVertical.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/CreateNodesStressbalanceVertical.cpp	(revision 16343)
@@ -11,6 +11,6 @@
 void	CreateNodesStressbalanceVertical(Nodes** pnodes, IoModel* iomodel){
 
-	/*Now, is the flag macayaealHO on? otherwise, do nothing: */
-	if(iomodel->meshtype==Mesh2DhorizontalEnum) return;
+	/*return if not 3d mesh*/
+	if(iomodel->meshtype!=Mesh3DEnum) return;
 
 	iomodel->FetchData(3,MeshVertexonbedEnum,MeshVertexonsurfaceEnum,FlowequationVertexEquationEnum);
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/UpdateElementsStressbalanceVertical.cpp
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/UpdateElementsStressbalanceVertical.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/StressbalanceVertical/UpdateElementsStressbalanceVertical.cpp	(revision 16343)
@@ -11,6 +11,6 @@
 void	UpdateElementsStressbalanceVertical(Elements* elements, IoModel* iomodel,int analysis_counter,int analysis_type){
 
-	/*Now, is the model 3d? otherwise, do nothing: */
-	if (iomodel->meshtype==Mesh2DhorizontalEnum)return;
+	/*return if not 3d mesh*/
+	if(iomodel->meshtype!=Mesh3DEnum) return;
 
 	/*Update elements: */
Index: /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 16342)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h	(revision 16343)
@@ -403,4 +403,6 @@
 	StringArrayParamEnum,
 	StringParamEnum,
+	SegEnum,
+	SegInputEnum,
 	TriaEnum,
 	TriaInputEnum,
@@ -611,5 +613,4 @@
 	/*Coordinate Systems{{{*/
 	XYEnum,
-	XZEnum,
 	XYZEnum,
 	/*}}}*/
Index: /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp	(revision 16343)
@@ -403,4 +403,6 @@
 		case StringArrayParamEnum : return "StringArrayParam";
 		case StringParamEnum : return "StringParam";
+		case SegEnum : return "Seg";
+		case SegInputEnum : return "SegInput";
 		case TriaEnum : return "Tria";
 		case TriaInputEnum : return "TriaInput";
@@ -587,5 +589,4 @@
 		case NearestInterpEnum : return "NearestInterp";
 		case XYEnum : return "XY";
-		case XZEnum : return "XZ";
 		case XYZEnum : return "XYZ";
 		case DenseEnum : return "Dense";
Index: /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 16342)
+++ /issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp	(revision 16343)
@@ -412,4 +412,6 @@
 	      else if (strcmp(name,"StringArrayParam")==0) return StringArrayParamEnum;
 	      else if (strcmp(name,"StringParam")==0) return StringParamEnum;
+	      else if (strcmp(name,"Seg")==0) return SegEnum;
+	      else if (strcmp(name,"SegInput")==0) return SegInputEnum;
 	      else if (strcmp(name,"Tria")==0) return TriaEnum;
 	      else if (strcmp(name,"TriaInput")==0) return TriaInputEnum;
@@ -504,10 +506,10 @@
 	      else if (strcmp(name,"StressTensorxy")==0) return StressTensorxyEnum;
 	      else if (strcmp(name,"StressTensorxz")==0) return StressTensorxzEnum;
-	      else if (strcmp(name,"StressTensoryy")==0) return StressTensoryyEnum;
-	      else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
          else stage=5;
    }
    if(stage==5){
-	      if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
+	      if (strcmp(name,"StressTensoryy")==0) return StressTensoryyEnum;
+	      else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
+	      else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
 	      else if (strcmp(name,"GiaCrossSectionShape")==0) return GiaCrossSectionShapeEnum;
 	      else if (strcmp(name,"GiadWdt")==0) return GiadWdtEnum;
@@ -599,5 +601,4 @@
 	      else if (strcmp(name,"NearestInterp")==0) return NearestInterpEnum;
 	      else if (strcmp(name,"XY")==0) return XYEnum;
-	      else if (strcmp(name,"XZ")==0) return XZEnum;
 	      else if (strcmp(name,"XYZ")==0) return XYZEnum;
 	      else if (strcmp(name,"Dense")==0) return DenseEnum;
Index: /issm/trunk-jpl/src/m/classes/mesh2dvertical.m
===================================================================
--- /issm/trunk-jpl/src/m/classes/mesh2dvertical.m	(revision 16342)
+++ /issm/trunk-jpl/src/m/classes/mesh2dvertical.m	(revision 16343)
@@ -7,5 +7,5 @@
 	properties (SetAccess=public) 
 		x                           = NaN;
-		z                           = NaN;
+		y                           = NaN;
 		elements                    = NaN
 		numberofelements            = 0;
@@ -48,5 +48,5 @@
 
 			md = checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]);
-			md = checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices 1]);
+			md = checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices 1]);
 			md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values',1:md.mesh.numberofvertices);
 			md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 3]);
@@ -72,5 +72,5 @@
 			fielddisplay(obj,'elements','vertex indices of the mesh elements');
 			fielddisplay(obj,'x','vertices x coordinate [m]');
-			fielddisplay(obj,'z','vertices z coordinate [m]');
+			fielddisplay(obj,'y','vertices y coordinate [m]');
 			fielddisplay(obj,'edges','edges of the 2d mesh (vertex1 vertex2 element1 element2)');
 			fielddisplay(obj,'numberofedges','number of edges of the 2d mesh');
@@ -85,8 +85,4 @@
 			fielddisplay(obj,'average_vertex_connectivity','average number of vertices connected to one vertex');
 
-			disp(sprintf('\n      Extracted model:'));
-			fielddisplay(obj,'extractedvertices','vertices extracted from the model');
-			fielddisplay(obj,'extractedelements','elements extracted from the model');
-
 			disp(sprintf('\n      Projection:'));
 			fielddisplay(obj,'lat','vertices latitude [degrees]');
@@ -97,6 +93,6 @@
 			WriteData(fid,'enum',MeshTypeEnum(),'data',StringToEnum(['Mesh' meshtype(obj)]),'format','Integer');
 			WriteData(fid,'object',obj,'class','mesh','fieldname','x','format','DoubleMat','mattype',1);
-			WriteData(fid,'object',obj,'class','mesh','fieldname','z','format','DoubleMat','mattype',1);
-			WriteData(fid,'enum',MeshYEnum(),'data',zeros(obj.numberofvertices,1),'format','DoubleMat','mattype',1);
+			WriteData(fid,'object',obj,'class','mesh','fieldname','y','format','DoubleMat','mattype',1);
+			WriteData(fid,'enum',MeshZEnum(),'data',zeros(obj.numberofvertices,1),'format','DoubleMat','mattype',1);
 			WriteData(fid,'object',obj,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2);
 			WriteData(fid,'object',obj,'class','mesh','fieldname','numberofelements','format','Integer');
@@ -207,5 +203,5 @@
 			elements = self.elements;
 			x        = self.x;
-			y        = self.z;
+			y        = self.y;
 			z        = zeros(self.numberofvertices,1);
 		end % }}}
Index: /issm/trunk-jpl/src/m/enum/EnumDefinitions.py
===================================================================
--- /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 16342)
+++ /issm/trunk-jpl/src/m/enum/EnumDefinitions.py	(revision 16343)
@@ -395,4 +395,6 @@
 def StringArrayParamEnum(): return StringToEnum("StringArrayParam")[0]
 def StringParamEnum(): return StringToEnum("StringParam")[0]
+def SegEnum(): return StringToEnum("Seg")[0]
+def SegInputEnum(): return StringToEnum("SegInput")[0]
 def TriaEnum(): return StringToEnum("Tria")[0]
 def TriaInputEnum(): return StringToEnum("TriaInput")[0]
@@ -579,5 +581,4 @@
 def NearestInterpEnum(): return StringToEnum("NearestInterp")[0]
 def XYEnum(): return StringToEnum("XY")[0]
-def XZEnum(): return StringToEnum("XZ")[0]
 def XYZEnum(): return StringToEnum("XYZ")[0]
 def DenseEnum(): return StringToEnum("Dense")[0]
Index: /issm/trunk-jpl/src/m/enum/SegEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/SegEnum.m	(revision 16343)
+++ /issm/trunk-jpl/src/m/enum/SegEnum.m	(revision 16343)
@@ -0,0 +1,11 @@
+function macro=SegEnum()
+%SEGENUM - Enum of Seg
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
+%            Please read src/c/shared/Enum/README for more information
+%
+%   Usage:
+%      macro=SegEnum()
+
+macro=StringToEnum('Seg');
Index: /issm/trunk-jpl/src/m/enum/SegInputEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/SegInputEnum.m	(revision 16343)
+++ /issm/trunk-jpl/src/m/enum/SegInputEnum.m	(revision 16343)
@@ -0,0 +1,11 @@
+function macro=SegInputEnum()
+%SEGINPUTENUM - Enum of SegInput
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
+%            Please read src/c/shared/Enum/README for more information
+%
+%   Usage:
+%      macro=SegInputEnum()
+
+macro=StringToEnum('SegInput');
Index: sm/trunk-jpl/src/m/enum/XZEnum.m
===================================================================
--- /issm/trunk-jpl/src/m/enum/XZEnum.m	(revision 16342)
+++ 	(revision )
@@ -1,11 +1,0 @@
-function macro=XZEnum()
-%XZENUM - Enum of XZ
-%
-%   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/shared/Enum/Synchronize.sh
-%            Please read src/c/shared/Enum/README for more information
-%
-%   Usage:
-%      macro=XZEnum()
-
-macro=StringToEnum('XZ');
Index: /issm/trunk-jpl/src/m/mesh/bamg.m
===================================================================
--- /issm/trunk-jpl/src/m/mesh/bamg.m	(revision 16342)
+++ /issm/trunk-jpl/src/m/mesh/bamg.m	(revision 16343)
@@ -328,5 +328,5 @@
 	md.mesh=mesh2dvertical;
 	md.mesh.x=bamgmesh_out.Vertices(:,1);
-	md.mesh.z=bamgmesh_out.Vertices(:,2);
+	md.mesh.y=bamgmesh_out.Vertices(:,2);
 	md.mesh.elements=bamgmesh_out.Triangles(:,1:3);
 	md.mesh.edges=bamgmesh_out.IssmEdges;
