Index: issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/EnthalpyAnalysis.cpp	(revision 18521)
@@ -880,5 +880,5 @@
 		/*Drain excess water fraction in ice column: */
 		for(i=0;i<femmodel->elements->Size();i++){
-			Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+			Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 			DrainWaterfractionIcecolumn(element);
 		}
@@ -888,5 +888,5 @@
 		/*Compute basal melting rates: */
 		for(i=0;i<femmodel->elements->Size();i++){
-			Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+			Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 			ComputeBasalMeltingrate(element);
 		}
@@ -898,5 +898,5 @@
 		if(solution_type==TransientSolutionEnum){
 			for(i=0;i<femmodel->elements->Size();i++){
-				Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+				Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 				UpdateBasalConstraints(element);
 			}
Index: issm/trunk-jpl/src/c/analyses/ExtrapolationAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/ExtrapolationAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/ExtrapolationAnalysis.cpp	(revision 18521)
@@ -350,5 +350,5 @@
 
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		this->SetConstraintsOnIce(element);
 	}
Index: issm/trunk-jpl/src/c/analyses/FreeSurfaceBaseAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/FreeSurfaceBaseAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/FreeSurfaceBaseAnalysis.cpp	(revision 18521)
@@ -377,5 +377,5 @@
 	for(int i=0;i<femmodel->elements->Size();i++){
 
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		if(!element->IsOnBase()) continue;
 
Index: issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/HydrologyDCInefficientAnalysis.cpp	(revision 18521)
@@ -692,5 +692,5 @@
 
 	for(int i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		int numvertices = element->GetNumberOfVertices();
Index: issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/LevelsetAnalysis.cpp	(revision 18521)
@@ -399,5 +399,5 @@
 	/* set NaN on elements intersected by zero levelset */
 	for(i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		if(element->IsZeroLevelset(MaskIceLevelsetEnum))
 			for(k=0;k<element->GetNumberOfVertices();k++)
@@ -407,5 +407,5 @@
 	/* set distance on elements intersected by zero levelset */
 	for(i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		if(element->IsZeroLevelset(MaskIceLevelsetEnum)){
 			SetDistanceToZeroLevelsetElement(vec_dist_zerolevelset, element);
Index: issm/trunk-jpl/src/c/analyses/LsfReinitializationAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/LsfReinitializationAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/LsfReinitializationAnalysis.cpp	(revision 18521)
@@ -369,5 +369,5 @@
 	/* deactivate all spcs */
 	for(i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		for(k=0;k<element->GetNumberOfNodes();k++){
 			node=element->GetNode(k);
@@ -382,5 +382,5 @@
 	/* reactivate spcs on elements intersected by zero levelset */
 	for(i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		if(element->IsZeroLevelset(MaskIceLevelsetEnum)){
 			/*iterate over nodes and set spc */
@@ -414,5 +414,5 @@
 	/* set distance on elements intersected by zero levelset */
 	for(i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		if(element->IsZeroLevelset(MaskIceLevelsetEnum)){
 			SetDistanceToZeroLevelsetElement(vec_dist_zerolevelset, element);
Index: issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/MasstransportAnalysis.cpp	(revision 18521)
@@ -796,5 +796,5 @@
 	/*Create and assemble matrix*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element*       element = dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element*       element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		ElementMatrix* MLe     = this->CreateMassMatrix(element);
 		if(MLe){
@@ -817,5 +817,5 @@
 	/*Create and assemble matrix*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element*       element = dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element*       element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		ElementMatrix* MLe     = this->CreateMassMatrix(element);
 		if(MLe){
@@ -880,5 +880,5 @@
 	/*Create and assemble matrix*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element*       element = dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element*       element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		ElementMatrix* Ke     = this->CreateFctKMatrix(element);
 		if(Ke) Ke->AddToGlobal(Kff,Kfs);
Index: issm/trunk-jpl/src/c/analyses/SeaiceAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/SeaiceAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/SeaiceAnalysis.cpp	(revision 18521)
@@ -372,5 +372,5 @@
 	mask=new Vector<IssmDouble>(femmodel->nodes->NumberOfNodes(SeaiceAnalysisEnum));
 	for (int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		/*Get current concentration of element and decide whether it is an active element*/
@@ -390,5 +390,5 @@
 	int counter =0;
 	for(int i=0;i<femmodel->nodes->Size();i++){
-		Node* node=dynamic_cast<Node*>(femmodel->nodes->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(femmodel->nodes->GetObjectByOffset(i));
 		if(node->InAnalysis(SeaiceAnalysisEnum)){
 			if(serial_mask[node->Sid()]==1.){
@@ -552,5 +552,5 @@
 	/*Loop over the elements of this partition and update accordingly*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		/*Get Mohr-Coulomb parameters*/
@@ -644,5 +644,5 @@
 	/*Loop over the elements of this partition and update accordingly*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		/*Get some inputs needed for the update*/
Index: issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp
===================================================================
--- issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/analyses/StressbalanceAnalysis.cpp	(revision 18521)
@@ -5032,5 +5032,5 @@
 
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 
 		/*Get inputs and parameters*/
@@ -5206,5 +5206,5 @@
 
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 
 		/*Get inputs and parameters*/
@@ -5419,5 +5419,5 @@
 
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 
 		/*Get inputs and parameters*/
@@ -6788,5 +6788,5 @@
 	/*Cast gauss to GaussPenta*/
 	_assert_(gauss_in->Enum()==GaussPentaEnum);
-	GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);
+	GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in);
 
 	/*Get basis in actual coordinate system: */
@@ -6837,5 +6837,5 @@
 	/*Cast gauss to GaussPenta*/
 	_assert_(gauss_in->Enum()==GaussPentaEnum);
-	GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);
+	GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in);
 
 	/*Get basis in actual coordinate system: */
@@ -6936,5 +6936,5 @@
 	/*Cast gauss to GaussPenta*/
 	_assert_(gauss_in->Enum()==GaussPentaEnum);
-	GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);
+	GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in);
 
 	/*Get basis in actual coordinate system: */
@@ -6974,5 +6974,5 @@
 	/*Cast gauss to GaussPenta*/
 	_assert_(gauss_in->Enum()==GaussPentaEnum);
-	GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);
+	GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in);
 
 	/*Get basis in actual coordinate system: */
Index: issm/trunk-jpl/src/c/classes/Elements/Elements.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Elements.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Elements/Elements.cpp	(revision 18521)
@@ -41,5 +41,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		element=dynamic_cast<Element*>((*object));
+		element=xDynamicCast<Element*>((*object));
 		element->Configure(elements,loads,nodes,vertices,materials,parameters);
 
@@ -55,5 +55,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		element=dynamic_cast<Element*>((*object));
+		element=xDynamicCast<Element*>((*object));
 		element->SetCurrentConfiguration(elements,loads,nodes,materials,parameters);
 
@@ -69,5 +69,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		element=dynamic_cast<Element*>((*object));
+		element=xDynamicCast<Element*>((*object));
 		element->ResetHooks();
 
@@ -85,5 +85,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->GetObjectByOffset(i));
 		numnodes=element->GetNumberOfNodes();
 		if(numnodes>max)max=numnodes;
@@ -111,5 +111,5 @@
 
 	for(int i=0;i<this->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->GetObjectByOffset(i));
 		element->InputDuplicate(input_enum,output_enum);
 	}
Index: issm/trunk-jpl/src/c/classes/Elements/Penta.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Elements/Penta.cpp	(revision 18521)
@@ -1970,5 +1970,5 @@
 	tria->parameters=this->parameters;
 	tria->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED)
-	this->SpawnTriaHook(dynamic_cast<ElementHook*>(tria),index1,index2,index3);
+	this->SpawnTriaHook(xDynamicCast<ElementHook*>(tria),index1,index2,index3);
 
 	/*Spawn material*/
Index: issm/trunk-jpl/src/c/classes/Elements/PentaRef.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/PentaRef.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Elements/PentaRef.cpp	(revision 18521)
@@ -48,5 +48,5 @@
 	/*Cast gauss to GaussPenta*/
 	_assert_(gauss_in->Enum()==GaussPentaEnum);
-	GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);
+	GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in);
 
 	/*Figure out xi,eta and zi (parametric coordinates), for this gaussian point: */
@@ -160,5 +160,5 @@
 	/*Cast gauss to GaussPenta*/
 	_assert_(gauss_in->Enum()==GaussPentaEnum);
-	GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);
+	GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in);
 
 	/*Get current coordinates in reference element*/
@@ -365,5 +365,5 @@
 	/*Cast gauss to GaussPenta*/
 	_assert_(gauss_in->Enum()==GaussPentaEnum);
-	GaussPenta* gauss = dynamic_cast<GaussPenta*>(gauss_in);
+	GaussPenta* gauss = xDynamicCast<GaussPenta*>(gauss_in);
 
 	/*Get current coordinates in reference element*/
Index: issm/trunk-jpl/src/c/classes/Elements/Tetra.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Tetra.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Elements/Tetra.cpp	(revision 18521)
@@ -824,5 +824,5 @@
 	tria->parameters=this->parameters;
 	tria->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED)
-	this->SpawnTriaHook(dynamic_cast<ElementHook*>(tria),index1,index2,index3);
+	this->SpawnTriaHook(xDynamicCast<ElementHook*>(tria),index1,index2,index3);
 
 	/*Spawn material*/
Index: issm/trunk-jpl/src/c/classes/Elements/TetraRef.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/TetraRef.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Elements/TetraRef.cpp	(revision 18521)
@@ -37,5 +37,5 @@
 	/*Cast gauss to GaussTetra*/
 	_assert_(gauss_in->Enum()==GaussTetraEnum);
-	GaussTetra* gauss = dynamic_cast<GaussTetra*>(gauss_in);
+	GaussTetra* gauss = xDynamicCast<GaussTetra*>(gauss_in);
 
 	switch(finiteelement){
Index: issm/trunk-jpl/src/c/classes/Elements/Tria.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Elements/Tria.cpp	(revision 18521)
@@ -1796,5 +1796,5 @@
 	seg->parameters=this->parameters;
 	seg->element_type=P1Enum; //Only P1 CG for now (TO BE CHANGED)
-	this->SpawnSegHook(dynamic_cast<ElementHook*>(seg),index1,index2);
+	this->SpawnSegHook(xDynamicCast<ElementHook*>(seg),index1,index2);
 
 	/*Spawn material*/
Index: issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Elements/TriaRef.cpp	(revision 18521)
@@ -146,5 +146,5 @@
 	/*Cast gauss to GaussTria*/
 	_assert_(gauss_in->Enum()==GaussTriaEnum);
-	GaussTria* gauss = dynamic_cast<GaussTria*>(gauss_in);
+	GaussTria* gauss = xDynamicCast<GaussTria*>(gauss_in);
 
 	switch(finiteelement){
@@ -271,5 +271,5 @@
 	/*Cast gauss to GaussTria*/
 	_assert_(gauss_in->Enum()==GaussTriaEnum);
-	GaussTria* gauss = dynamic_cast<GaussTria*>(gauss_in);
+	GaussTria* gauss = xDynamicCast<GaussTria*>(gauss_in);
 
 	switch(finiteelement){
Index: issm/trunk-jpl/src/c/classes/ExternalResults/Results.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/ExternalResults/Results.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/ExternalResults/Results.cpp	(revision 18521)
@@ -41,5 +41,5 @@
 
 	for(int i=0;i<this->Size();i++){
-		ExternalResult* result=dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i));
+		ExternalResult* result=xDynamicCast<ExternalResult*>(this->GetObjectByOffset(i));
 		result->WriteData(fid,io_gather);
 	}
@@ -57,5 +57,5 @@
 
 	for(int i=0;i<this->Size();i++){
-		ExternalResult* result=dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i));
+		ExternalResult* result=xDynamicCast<ExternalResult*>(this->GetObjectByOffset(i));
 
 		if(result->GetStep()==in_result->GetStep()){
@@ -81,5 +81,5 @@
 
 	for(int i=0;i<this->Size();i++){
-		ExternalResult* result=dynamic_cast<ExternalResult*>(this->GetObjectByOffset(i));
+		ExternalResult* result=xDynamicCast<ExternalResult*>(this->GetObjectByOffset(i));
 
 		if(result->GetStep()==result_step){
Index: issm/trunk-jpl/src/c/classes/FemModel.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/FemModel.cpp	(revision 18521)
@@ -603,5 +603,5 @@
 					/*Get interpolation (and compute input if necessary)*/
 					for(int j=0;j<elements->Size();j++){
-						Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(j));
+						Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(j));
 						element->ResultInterpolation(&rank_interpolation,&rank_nodesperelement,output_enum);
 					}
@@ -622,5 +622,5 @@
 						/*Fill-in matrix*/
 						for(int j=0;j<elements->Size();j++){
-							Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(j));
+							Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(j));
 							element->ResultToPatch(values,nodesperelement,output_enum);
 						}
@@ -739,5 +739,5 @@
 
 	for (i=1;i<elements->Size();i++){
-		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		dt=element->TimeAdapt();
 		if(dt<min_dt)min_dt=dt;
@@ -756,5 +756,5 @@
 
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->UpdateConstraintsExtrudeFromBase();
 	}
@@ -765,5 +765,5 @@
 
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->UpdateConstraintsExtrudeFromTop();
 	}
@@ -839,5 +839,5 @@
 	maxabsvx=-INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_maxabsvx=element->inputs->MaxAbs(VxEnum);
 		if(element_maxabsvx>maxabsvx) maxabsvx=element_maxabsvx;
@@ -863,5 +863,5 @@
 	maxabsvy=-INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_maxabsvy=element->inputs->MaxAbs(VyEnum);
 		if(element_maxabsvy>maxabsvy) maxabsvy=element_maxabsvy;
@@ -887,5 +887,5 @@
 	maxabsvz=-INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_maxabsvz=element->inputs->MaxAbs(VzEnum);
 		if(element_maxabsvz>maxabsvz) maxabsvz=element_maxabsvz;
@@ -911,5 +911,5 @@
 	maxvel=-INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_maxvel = element->inputs->Max(VelEnum);
 		if(element_maxvel>maxvel) maxvel=element_maxvel;
@@ -935,5 +935,5 @@
 	maxvx=-INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_maxvx = element->inputs->Max(VxEnum);
 		if(element_maxvx>maxvx) maxvx=element_maxvx;
@@ -959,5 +959,5 @@
 	maxvy=-INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_maxvy = element->inputs->Max(VyEnum);
 		if(element_maxvy>maxvy) maxvy=element_maxvy;
@@ -983,5 +983,5 @@
 	maxvz=-INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_maxvz = element->inputs->Max(VzEnum);
 		if(element_maxvz>maxvz) maxvz=element_maxvz;
@@ -1007,5 +1007,5 @@
 	minvel=INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_minvel = element->inputs->Min(VelEnum);
 		if(element_minvel<minvel) minvel=element_minvel;
@@ -1031,5 +1031,5 @@
 	minvx=INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_minvx = element->inputs->Min(VxEnum);
 		if(element_minvx<minvx) minvx=element_minvx;
@@ -1055,5 +1055,5 @@
 	minvy=INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_minvy = element->inputs->Min(VyEnum);
 		if(element_minvy<minvy) minvy=element_minvy;
@@ -1079,5 +1079,5 @@
 	minvz=INFINITY;
 	for(i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element_minvz = element->inputs->Min(VzEnum);
 		if(element_minvz<minvz) minvz=element_minvz;
@@ -1099,5 +1099,5 @@
 
 	for(int i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		local_smb+=element->TotalSmb();
 	}
@@ -1115,5 +1115,5 @@
 
 	for(int i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		local_divergence+=element->Divergence();
 	}
@@ -1143,5 +1143,5 @@
 
 	for(int i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		element->GetInputLocalMinMaxOnNodes(uLmin_local,uLmax_local,ug);
 	}
@@ -1164,5 +1164,5 @@
 
 	for(int i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		local_ice_volume+=element->IceVolume();
 	}
@@ -1180,5 +1180,5 @@
 
 	for(int i=0;i<this->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		local_ice_volume_af+=element->IceVolumeAboveFloatation();
 	}
@@ -1205,5 +1205,5 @@
 	/*now, go through our elements, and retrieve the one with this id: index: */
 	for(int i=0;i<this->elements->Size();i++){
-		element=dynamic_cast<Element*>(this->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(this->elements->GetObjectByOffset(i));
 		if (element->Id()==index){
 			found=1;
@@ -1243,5 +1243,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 
 		/*If on water, return 0: */
@@ -1311,5 +1311,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 
 		/*If on water, return 0: */
@@ -1341,5 +1341,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 
 		/*If on water, return 0: */
@@ -1572,5 +1572,5 @@
 	/*Go through elements, and add contribution from each element to the deflection vector wg:*/
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->GiaDeflection(wg,dwgdt, x,y);
 	}
@@ -1590,5 +1590,5 @@
 
 	for (int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		effanalysis->HydrologyEPLGetMask(mask,element);
 	}
@@ -1606,5 +1606,5 @@
 	active=new Vector<IssmDouble>(nodes->NumberOfNodes(HydrologyDCEfficientAnalysisEnum));
 	for (int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		effanalysis->HydrologyEPLGetActive(active,element);
 	}
@@ -1618,5 +1618,5 @@
 	int counter =0;
 	for (int i=0;i<nodes->Size();i++){
-		Node* node=dynamic_cast<Node*>(nodes->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(nodes->GetObjectByOffset(i));
 		if(node->InAnalysis(HydrologyDCEfficientAnalysisEnum)){
 			if(serial_active[node->Sid()]==1.){
@@ -1651,5 +1651,5 @@
 	active=new Vector<IssmDouble>(nodes->NumberOfNodes(HydrologyDCEfficientAnalysisEnum));
 	for (int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		effanalysis->HydrologyEPLGetActive(active,element);
 	}
@@ -1664,5 +1664,5 @@
 	int counter =0;
 	for (int i=0;i<nodes->Size();i++){
-		Node* node=dynamic_cast<Node*>(nodes->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(nodes->GetObjectByOffset(i));
 		if(node->InAnalysis(L2ProjectionEPLAnalysisEnum)){
 			if(serial_active[node->Sid()]==1.){
Index: issm/trunk-jpl/src/c/classes/Hook.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Hook.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Hook.cpp	(revision 18521)
@@ -168,5 +168,5 @@
 		/*Now, for this->objects that did not get resolved, and for which we have no offset, chase them in the dataset, by id: */
 		if(this->objects[i]==NULL){
-			this->objects[i]=dynamic_cast<Object*>(dataset->GetObjectById(this->offsets+i,this->ids[i])); //remember the offset for later on.
+			this->objects[i]=xDynamicCast<Object*>(dataset->GetObjectById(this->offsets+i,this->ids[i])); //remember the offset for later on.
 			/*check the id is correct!: */
 			if (this->objects[i]->Id()!=this->ids[i]) _error_("wrong id: " << this->objects[i]->Id() << " vs " << this->ids[i] << "  in resolved pointer!");
Index: issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Inputs/ControlInput.cpp	(revision 18521)
@@ -87,9 +87,9 @@
 	output->control_id=this->control_id;
 
-	if(values)      output->values      = dynamic_cast<Input*>(this->values->copy());
-	if(savedvalues) output->savedvalues = dynamic_cast<Input*>(this->savedvalues->copy());
-	if(minvalues)   output->minvalues   = dynamic_cast<Input*>(this->minvalues->copy());
-	if(maxvalues)   output->maxvalues   = dynamic_cast<Input*>(this->maxvalues->copy());
-	if(gradient)    output->gradient    = dynamic_cast<Input*>(this->gradient->copy());
+	if(values)      output->values      = xDynamicCast<Input*>(this->values->copy());
+	if(savedvalues) output->savedvalues = xDynamicCast<Input*>(this->savedvalues->copy());
+	if(minvalues)   output->minvalues   = xDynamicCast<Input*>(this->minvalues->copy());
+	if(maxvalues)   output->maxvalues   = xDynamicCast<Input*>(this->maxvalues->copy());
+	if(gradient)    output->gradient    = xDynamicCast<Input*>(this->gradient->copy());
 
 	return output;
@@ -234,5 +234,5 @@
 
 	if(savedvalues) delete this->savedvalues;
-	this->savedvalues=dynamic_cast<Input*>(this->values->copy());
+	this->savedvalues=xDynamicCast<Input*>(this->values->copy());
 }/*}}}*/
 void ControlInput::UpdateValue(IssmDouble scalar){/*{{{*/
@@ -241,5 +241,5 @@
 
 	if(values) delete this->values;
-	this->values=dynamic_cast<Input*>(this->savedvalues->copy());
+	this->values=xDynamicCast<Input*>(this->savedvalues->copy());
 	this->values->AXPY(gradient,scalar);
 }/*}}}*/
Index: issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Inputs/DatasetInput.cpp	(revision 18521)
@@ -81,5 +81,5 @@
 	outinput=new DatasetInput();
 	outinput->enum_type=this->enum_type;
-	outinput->inputs=dynamic_cast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));
+	outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnTriaInputs(index1,index2,index3));
 	outinput->numids=this->numids;
 	outinput->ids=xNew<int>(this->numids);
@@ -98,5 +98,5 @@
 	outinput=new DatasetInput();
 	outinput->enum_type=this->enum_type;
-	outinput->inputs=dynamic_cast<Inputs*>(this->inputs->SpawnSegInputs(index1,index2));
+	outinput->inputs=xDynamicCast<Inputs*>(this->inputs->SpawnSegInputs(index1,index2));
 	outinput->numids=this->numids;
 	outinput->ids=xNew<int>(this->numids);
@@ -157,5 +157,5 @@
 	if(offset<0) _error_("Could not find input of id "<<id );
 
-	Input* input=dynamic_cast<Input*>(this->inputs->GetObjectByOffset(offset));
+	Input* input=xDynamicCast<Input*>(this->inputs->GetObjectByOffset(offset));
 	input->GetInputValue(pvalue,gauss);
 }
Index: issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Inputs/Inputs.cpp	(revision 18521)
@@ -38,5 +38,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 		if (input->InstanceEnum()==enum_type){
 			found=true;
@@ -65,5 +65,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 		if (input->InstanceEnum()==enum_type){
 			found=true;
@@ -92,5 +92,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object); 
+		input=xDynamicCast<Input*>(*object); 
 		if (input->InstanceEnum()==enum_type){
 			found=true;
@@ -119,5 +119,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 		if (input->InstanceEnum()==enum_type){
 			found=true;
@@ -150,5 +150,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 
 		if (input->InstanceEnum()==in_input->InstanceEnum()){
@@ -171,5 +171,5 @@
 	/*Delete existing input of newenumtype if it exists*/
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 
 		if (input->InstanceEnum()==newenumtype){
@@ -182,5 +182,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 
 		if (input->InstanceEnum()==oldenumtype){
@@ -194,5 +194,5 @@
 
 	/*Find x and y inputs: */
-	Input* constrain_input=dynamic_cast<Input*>(this->GetInput(constrain_enum));
+	Input* constrain_input=xDynamicCast<Input*>(this->GetInput(constrain_enum));
 
 	/*some checks: */
@@ -209,5 +209,5 @@
 
 	/*Get input*/
-	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
+	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
@@ -229,5 +229,5 @@
 
 	/*Get input*/
-	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
+	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
@@ -249,5 +249,5 @@
 
 	/*Get input*/
-	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
+	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
@@ -269,5 +269,5 @@
 
 	/*Get input*/
-	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
+	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
@@ -289,5 +289,5 @@
 
 	/*Get input*/
-	Input* input=dynamic_cast<Input*>(this->GetInput(enumtype));
+	Input* input=xDynamicCast<Input*>(this->GetInput(enumtype));
 
 	/*Apply ContrainMin: */
@@ -310,5 +310,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 
 		if (input->InstanceEnum()==enum_name){
@@ -326,5 +326,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 
 		if (input->InstanceEnum()==enum_type){
@@ -341,7 +341,7 @@
 
 	/*Make a copy of the original input: */
-	Input* original=dynamic_cast<Input*>(this->GetInput(original_enum));
+	Input* original=xDynamicCast<Input*>(this->GetInput(original_enum));
 	if(!original)_error_("could not find input with enum: " << EnumToStringx(original_enum)); 
-	Input* copy=dynamic_cast<Input*>(original->copy());
+	Input* copy=xDynamicCast<Input*>(original->copy());
 
 	/*Change copy enum to reinitialized_enum: */
@@ -349,5 +349,5 @@
 
 	/*Add copy into inputs, it will wipe off the one already there: */
-	this->AddInput(dynamic_cast<Input*>(copy));
+	this->AddInput(xDynamicCast<Input*>(copy));
 }
 /*}}}*/
@@ -366,5 +366,5 @@
 
 		/*Create new input*/
-		inputin=dynamic_cast<Input*>(*object);
+		inputin=xDynamicCast<Input*>(*object);
 		inputout=inputin->SpawnTriaInput(index1,index2,index3);
 
@@ -391,5 +391,5 @@
 
 		/*Create new input*/
-		inputin=dynamic_cast<Input*>(*object);
+		inputin=xDynamicCast<Input*>(*object);
 		inputout=inputin->SpawnSegInput(index1,index2);
 
@@ -405,6 +405,6 @@
 
 	/*Find x and y inputs: */
-	Input* xinput=dynamic_cast<Input*>(this->GetInput(inputx_enum));
-	Input* yinput=dynamic_cast<Input*>(this->GetInput(inputy_enum));
+	Input* xinput=xDynamicCast<Input*>(this->GetInput(inputx_enum));
+	Input* yinput=xDynamicCast<Input*>(this->GetInput(inputy_enum));
 
 	/*some checks: */
@@ -423,5 +423,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		input=dynamic_cast<Input*>(*object);
+		input=xDynamicCast<Input*>(*object);
 		input->Configure(parameters);
 
Index: issm/trunk-jpl/src/c/classes/IoModel.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/IoModel.cpp	(revision 18521)
@@ -259,8 +259,8 @@
 
 	/*Find constant*/
-	Param* param=dynamic_cast<Param*>(this->constants->FindParamObject(constant_enum));
+	Param* param=xDynamicCast<Param*>(this->constants->FindParamObject(constant_enum));
 	if(!param) _error_("Constant " << EnumToStringx(constant_enum) << " not found in iomodel");
 
-	return dynamic_cast<Param*>(param->copy());
+	return xDynamicCast<Param*>(param->copy());
 }
 /*}}}*/
@@ -1455,5 +1455,5 @@
 
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		if(!doublearray) element->AddInput(vector_enum,&default_value,P0Enum); 
 		else             element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
@@ -1485,5 +1485,5 @@
 			this->FetchData(&boolean,vector_enum);
 			for(i=0;i<elements->Size();i++){
-				Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+				Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 				element->InputUpdateFromConstant(boolean,vector_enum);
 			}
@@ -1492,5 +1492,5 @@
 			this->FetchData(&integer,vector_enum);
 			for(i=0;i<elements->Size();i++){
-				Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+				Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 				element->InputUpdateFromConstant(integer,vector_enum);
 			}
@@ -1499,5 +1499,5 @@
 			this->FetchData(&scalar,vector_enum);
 			for(i=0;i<elements->Size();i++){
-				Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+				Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 				element->InputUpdateFromConstant(scalar,vector_enum);
 			}
@@ -1507,5 +1507,5 @@
 			if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in binary file");
 			for(i=0;i<elements->Size();i++){
-				Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+				Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 				element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 			}
@@ -1515,5 +1515,5 @@
 			if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in binary file");
 			for(i=0;i<elements->Size();i++){
-				Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+				Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 				element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 			}
@@ -1523,5 +1523,5 @@
 			if(!doublearray) _error_(EnumToStringx(vector_enum)<<" not found in binary file");
 			for(i=0;i<elements->Size();i++){
-				Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+				Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 				element->InputCreate(doublearray,this,M,N,vector_layout,vector_enum,code);//we need i to index into elements.
 			}
Index: issm/trunk-jpl/src/c/classes/Loads/Loads.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Loads/Loads.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Loads/Loads.cpp	(revision 18521)
@@ -41,5 +41,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		load=dynamic_cast<Load*>(*object);
+		load=xDynamicCast<Load*>(*object);
 		load->Configure(elements,loads,nodes,vertices,materials,parameters);
 
@@ -55,5 +55,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		load=dynamic_cast<Load*>((*object));
+		load=xDynamicCast<Load*>((*object));
 		load->ResetHooks();
 
@@ -70,5 +70,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+		Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i));
 		if (load->InAnalysis(analysis_type)){
 			if(load->IsPenalty()) ispenalty++;
@@ -95,5 +95,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+		Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i));
 		if (load->InAnalysis(analysis_type)){
 			numnodes=load->GetNumberOfNodes();
@@ -132,5 +132,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+		Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i));
 
 		/*Check that this load corresponds to our analysis currently being carried out: */
@@ -157,5 +157,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Load* load=dynamic_cast<Load*>(this->GetObjectByOffset(i));
+		Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i));
 
 		/*Check that this load corresponds to our analysis currently being carried out: */
@@ -173,5 +173,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		load=dynamic_cast<Load*>(*object);
+		load=xDynamicCast<Load*>(*object);
 		load->SetCurrentConfiguration(elements,loads,nodes,vertices,materials,parameters);
 
Index: issm/trunk-jpl/src/c/classes/Materials/Materials.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Materials/Materials.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Materials/Materials.cpp	(revision 18521)
@@ -37,5 +37,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		material=dynamic_cast<Material*>(*object);
+		material=xDynamicCast<Material*>(*object);
 		material->Configure(elements);
 
@@ -51,5 +51,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		material=dynamic_cast<Material*>((*object));
+		material=xDynamicCast<Material*>((*object));
 		material->ResetHooks();
 
Index: issm/trunk-jpl/src/c/classes/Nodes.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Nodes.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Nodes.cpp	(revision 18521)
@@ -49,5 +49,5 @@
 	/*Go through objects, and distribute dofs locally, from 0 to numberofdofsperobject*/
 	for(i=0;i<this->Size();i++){
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
@@ -72,5 +72,5 @@
 	for(i=0;i<this->Size();i++){
 		/*Check that this node corresponds to our analysis currently being carried out: */
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 		if (node->InAnalysis(analysis_type)){
 			node->OffsetDofs(dofcount,setenum);
@@ -89,5 +89,5 @@
 
 	for(i=0;i<this->Size();i++){
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 		if (node->InAnalysis(analysis_type)){
 			node->ShowTrueDofs(truedofs,maxdofspernode,setenum);//give maxdofspernode, column size, so that nodes can index into truedofs
@@ -99,5 +99,5 @@
 	/* Now every cpu knows the true dofs of everyone else that is not a clone*/
 	for(i=0;i<this->Size();i++){
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 		if (node->InAnalysis(analysis_type)){
 			node->UpdateCloneDofs(alltruedofs,maxdofspernode,setenum);
@@ -107,5 +107,5 @@
 	/*Update indexingupdateflag*/
 	for(i=0;i<this->Size();i++){
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 		if (node->InAnalysis(analysis_type)){
 			node->ReindexingDone();
@@ -148,5 +148,5 @@
 	for(i=0;i<this->Size();i++){
 
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
@@ -172,5 +172,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
@@ -197,5 +197,5 @@
 	if(!sorted){
 		for(int i=0;i<this->Size();i++){
-			Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+			Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 			id=node->Id();
 			if(id>max)max=id;
@@ -207,5 +207,5 @@
 		}
 		else{
-			Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(this->Size()-1));
+			Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(this->Size()-1));
 			max = node->Id();
 		}
@@ -238,5 +238,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
@@ -262,5 +262,5 @@
 	/*Now go through all nodes, and get how many dofs they own, unless they are clone nodes: */
 	for(int i=0;i<this->Size();i++){
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Ok, this object is a node, ask it to plug values into partition: */
@@ -284,5 +284,5 @@
 	for(i=0;i<this->Size();i++){
 
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
@@ -316,5 +316,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
@@ -335,5 +335,5 @@
 	for(int i=0;i<this->Size();i++){
 
-		Node* node=dynamic_cast<Node*>(this->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(this->GetObjectByOffset(i));
 
 		/*Check that this node corresponds to our analysis currently being carried out: */
Index: issm/trunk-jpl/src/c/classes/Options/Options.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Options/Options.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Options/Options.cpp	(revision 18521)
@@ -52,5 +52,5 @@
 	for(object=objects.begin();object<objects.end();object++){
 
-		option=dynamic_cast<Option*>(*object);
+		option=xDynamicCast<Option*>(*object);
 		if (!strcmp(option->Name(),name)){
 			_error_("Options \"" << name << "\" found multiple times");
@@ -73,5 +73,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		option=dynamic_cast<Option*>(*object);
+		option=xDynamicCast<Option*>(*object);
 		//option=(Option*)(*object); //C-like cast
 		/*There is a crash on some machines (Einar Olason) that needs to be fixed*/
Index: issm/trunk-jpl/src/c/classes/Options/Options.h
===================================================================
--- issm/trunk-jpl/src/c/classes/Options/Options.h	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Options/Options.h	(revision 18521)
@@ -26,5 +26,5 @@
 
 			/*Get option*/
-			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
+			GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
@@ -41,5 +41,5 @@
 
 			/*Get option*/
-			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
+			GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
@@ -57,5 +57,5 @@
 
 			/*Get option*/
-			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
+			GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
@@ -72,5 +72,5 @@
 
 			/*Get option*/
-			GenericOption<OptionType>* genericoption=dynamic_cast<GenericOption<OptionType>*>(GetOption(name));
+			GenericOption<OptionType>* genericoption=xDynamicCast<GenericOption<OptionType>*>(GetOption(name));
 
 			/*If the pointer is not NULL, the option has been found*/
@@ -92,5 +92,5 @@
 
 	/*Get option*/
-	GenericOption<char*>* genericoption=dynamic_cast<GenericOption<char*>*>(GetOption(name));
+	GenericOption<char*>* genericoption=xDynamicCast<GenericOption<char*>*>(GetOption(name));
 
 	/*If the pointer is not NULL, the option has been found*/
Index: issm/trunk-jpl/src/c/classes/Params/Parameters.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Params/Parameters.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Params/Parameters.cpp	(revision 18521)
@@ -57,5 +57,5 @@
 
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type) return true;
 	}
@@ -70,5 +70,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pbool);
@@ -86,5 +86,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pinteger);
@@ -102,5 +102,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pscalar);
@@ -118,5 +118,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pscalar,time);
@@ -134,5 +134,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pstring);
@@ -151,5 +151,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pstringarray,pM);
@@ -168,5 +168,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pintarray,pM);
@@ -185,5 +185,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pintarray,pM,pN);
@@ -202,5 +202,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pIssmDoublearray,pM);
@@ -219,5 +219,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pIssmDoublearray,pM,pN);
@@ -236,5 +236,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(parray,pM,pmdims_array,pndims_array);
@@ -252,5 +252,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pvec);
@@ -269,5 +269,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pmat);
@@ -286,5 +286,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pfid);
@@ -303,5 +303,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			param->GetParameterValue(pdataset);
@@ -318,5 +318,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(boolean); //already exists, just set it.
@@ -329,5 +329,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(integer); //already exists, just set it.
@@ -340,5 +340,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(scalar); //already exists, just set it.
@@ -351,5 +351,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(string); //already exists, just set it.
@@ -362,5 +362,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(stringarray,M); //already exists, just set it.
@@ -373,5 +373,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(IssmDoublearray,M); //already exists, just set it.
@@ -384,5 +384,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(IssmDoublearray,M,N); //already exists, just set it.
@@ -395,5 +395,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(intarray,M); //already exists, just set it.
@@ -406,5 +406,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(intarray,M,N); //already exists, just set it.
@@ -417,5 +417,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(vector); //already exists, just set it.
@@ -428,5 +428,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(matrix); //already exists, just set it.
@@ -439,5 +439,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(fid); //already exists, just set it.
@@ -450,5 +450,5 @@
 
 	/*first, figure out if the param has already been created: */
-	param=dynamic_cast<Param*>(this->FindParamObject(enum_type));
+	param=xDynamicCast<Param*>(this->FindParamObject(enum_type));
 
 	if(param) param->SetValue(dataset); //already exists, just set it.
@@ -464,5 +464,5 @@
 	for ( object=objects.begin() ; object < objects.end(); object++ ){
 
-		param=dynamic_cast<Param*>(*object);
+		param=xDynamicCast<Param*>(*object);
 		if(param->InstanceEnum()==enum_type){
 			return (*object);
Index: issm/trunk-jpl/src/c/classes/Vertices.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/Vertices.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/Vertices.cpp	(revision 18521)
@@ -52,5 +52,5 @@
 	/*Go through objects, and distribute pids locally, from 0 to numberofpidsperobject*/
 	for (i=0;i<this->Size();i++){
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		vertex->DistributePids(&pidcount);
 	}
@@ -72,5 +72,5 @@
 	}
 	for (i=0;i<this->Size();i++){
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		vertex->OffsetPids(pidcount);
 	}
@@ -82,5 +82,5 @@
 	alltruepids=xNewZeroInit<int>(numberofobjects);
 	for (i=0;i<this->Size();i++){
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		vertex->ShowTruePids(truepids);
 	}
@@ -89,5 +89,5 @@
 	/* Now every cpu knows the true pids of everyone else that is not a clone*/
 	for(i=0;i<this->Size();i++){
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		vertex->UpdateClonePids(alltruepids);
 	}
@@ -128,5 +128,5 @@
 	for(i=0;i<this->Size();i++){
 		/*For this object, decide whether it is a clone: */
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		vertex->SetClone(minranks);
 	}
@@ -145,5 +145,5 @@
 
 	for(i=0;i<this->Size();i++){
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		sid=vertex->Sid();
 		if (sid>max_sid)max_sid=sid;
@@ -172,5 +172,5 @@
 	for(int i=0;i<this->Size();i++){
 		/*Plug rank into ranks, according to id: */
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		sid=vertex->Sid();
 		ranks[sid]=my_rank; 
@@ -202,5 +202,5 @@
 
 		/*let vertex fill matrix: */
-		Vertex* vertex=dynamic_cast<Vertex*>(this->GetObjectByOffset(i));
+		Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
 		vertex->ToXYZ(xyz);
 	}
Index: issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/gauss/GaussPenta.cpp	(revision 18521)
@@ -8,4 +8,5 @@
 #include "../../shared/Exceptions/exceptions.h"
 #include "../../shared/MemOps/MemOps.h"
+#include "../../shared/Numerics/recast.h"
 #include "../../shared/Enum/Enum.h"
 #include "../../shared/Numerics/GaussPoints.h"
@@ -750,5 +751,5 @@
 
 	_assert_(gauss->Enum()==GaussTriaEnum);
-	GaussTria* gauss_tria = dynamic_cast<GaussTria*>(gauss);
+	GaussTria* gauss_tria = xDynamicCast<GaussTria*>(gauss);
 
 	gauss_tria->coord1=this->coord1;
Index: issm/trunk-jpl/src/c/classes/kriging/Observations.cpp
===================================================================
--- issm/trunk-jpl/src/c/classes/kriging/Observations.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/classes/kriging/Observations.cpp	(revision 18521)
@@ -89,5 +89,5 @@
 		this->quadtree->ClosestObs(&index,x[i],y[i]);
 		if(index>=0){
-			observation=dynamic_cast<Observation*>(this->GetObjectByOffset(index));
+			observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
 			if(pow(observation->x-x[i],2)+pow(observation->y-y[i],2) < minspacing) continue;
 		}
@@ -131,5 +131,5 @@
 	this->quadtree->ClosestObs(&index,x_interp,y_interp);
 	if(index>=0){
-		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(index));
+		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
 		hmin = sqrt((observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp));
 		if(hmin<radius) radius=hmin;
@@ -139,5 +139,5 @@
 	this->quadtree->RangeSearch(&indices,&nobs,x_interp,y_interp,radius);
 	for (i=0;i<nobs;i++){
-		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i]));
+		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i]));
 		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
 		if(i==0){
@@ -155,5 +155,5 @@
 	/*Assign output pointer*/
 	if(nobs || hmin==radius){
-		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(index));
+		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(index));
 		*px   = observation->x;
 		*py   = observation->y;
@@ -210,5 +210,5 @@
 	nobs = 0;
 	for(i=0;i<tempnobs;i++){
-		observation=dynamic_cast<Observation*>(this->GetObjectByOffset(tempindices[i]));
+		observation=xDynamicCast<Observation*>(this->GetObjectByOffset(tempindices[i]));
 		h2 = (observation->x-x_interp)*(observation->x-x_interp) + (observation->y-y_interp)*(observation->y-y_interp);
 
@@ -252,5 +252,5 @@
 		/*Loop over all observations and fill in x, y and obs*/
 		for(i=0;i<nobs;i++){
-			observation=dynamic_cast<Observation*>(this->GetObjectByOffset(indices[i]));
+			observation=xDynamicCast<Observation*>(this->GetObjectByOffset(indices[i]));
 			observation->WriteXYObs(&x[i],&y[i],&obs[i]);
 		}
@@ -280,5 +280,5 @@
 		obs = xNew<IssmPDouble>(nobs);
 		for(int i=0;i<this->Size();i++){
-			observation=dynamic_cast<Observation*>(this->GetObjectByOffset(i));
+			observation=xDynamicCast<Observation*>(this->GetObjectByOffset(i));
 			observation->WriteXYObs(&x[i],&y[i],&obs[i]);
 		}
@@ -532,8 +532,8 @@
 
 	for(i=0;i<this->Size();i++){
-		observation1=dynamic_cast<Observation*>(this->GetObjectByOffset(i));
+		observation1=xDynamicCast<Observation*>(this->GetObjectByOffset(i));
 
 		for(j=i+1;j<this->Size();j++){
-			observation2=dynamic_cast<Observation*>(this->GetObjectByOffset(j));
+			observation2=xDynamicCast<Observation*>(this->GetObjectByOffset(j));
 
 			distance=sqrt(pow(observation1->x - observation2->x,2) + pow(observation1->y - observation2->y,2));
Index: issm/trunk-jpl/src/c/cores/ad_core.cpp
===================================================================
--- issm/trunk-jpl/src/c/cores/ad_core.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/cores/ad_core.cpp	(revision 18521)
@@ -111,5 +111,5 @@
 
 			/*get the EDF pointer:*/
-			ext_diff_fct *anEDF_for_solverx_p=dynamic_cast<GenericParam<Adolc_edf> * >(femmodel->parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p;
+			ext_diff_fct *anEDF_for_solverx_p=xDynamicCast<GenericParam<Adolc_edf> * >(femmodel->parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p;
 
 			/*Branch according to AD driver: */
Index: issm/trunk-jpl/src/c/main/kriging.cpp
===================================================================
--- issm/trunk-jpl/src/c/main/kriging.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/main/kriging.cpp	(revision 18521)
@@ -58,5 +58,5 @@
 		results->AddObject(new GenericExternalResult<double*>(results->Size()+1,1,error,ninterp,1,1,0));
 		for(int i=0;i<results->Size();i++){
-			ExternalResult* result=dynamic_cast<ExternalResult*>(results->GetObjectByOffset(i));
+			ExternalResult* result=xDynamicCast<ExternalResult*>(results->GetObjectByOffset(i));
 			result->WriteData(output_fid,1);
 		}
Index: issm/trunk-jpl/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp	(revision 18521)
@@ -134,5 +134,5 @@
 	k=0;
 	for(i=0;i<femmodel->elements->Size();i++){
-		element = dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element = xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		lidlist = xNew<int>(element->GetNumberOfNodes());
 		element->GetNodesLidList(lidlist);
@@ -157,5 +157,5 @@
 	k=0;
 	for(i=0;i<femmodel->loads->Size();i++){
-		load = dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));
+		load = xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i));
 		if(!load->InAnalysis(configuration_type)) continue;
 		lidlist = xNew<int>(load->GetNumberOfNodes());
@@ -190,5 +190,5 @@
 	/*Create connectivity vector*/
 	for(i=0;i<femmodel->nodes->Size();i++){
-		Node* node=dynamic_cast<Node*>(femmodel->nodes->GetObjectByOffset(i));
+		Node* node=xDynamicCast<Node*>(femmodel->nodes->GetObjectByOffset(i));
 		if(node->InAnalysis(configuration_type)){
 
@@ -214,5 +214,5 @@
 			for(j=head_e[node->Lid()];j!=-1;j=next_e[j]){
 				offset=count2offset_e[j];
-				element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(offset));
+				element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(offset));
 				element->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,flagsindices,set1enum,set2enum);
 				if(node->IsClone()){
@@ -226,5 +226,5 @@
 			for(j=head_l[node->Lid()];j!=-1;j=next_l[j]){
 				offset=count2offset_l[j];
-				load=dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(offset));
+				load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(offset));
 				load->SetwiseNodeConnectivity(&d_nz,&o_nz,node,flags,flagsindices,set1enum,set2enum);
 				if(node->IsClone()){
@@ -256,5 +256,5 @@
 		o_nnz=xNew<int>(m);
 		for(i=0;i<femmodel->nodes->Size();i++){
-			Node* node=dynamic_cast<Node*>(femmodel->nodes->GetObjectByOffset(i));
+			Node* node=xDynamicCast<Node*>(femmodel->nodes->GetObjectByOffset(i));
 			if(node->InAnalysis(configuration_type) && !node->IsClone()){
 				for(j=0;j<node->indexing.fsize;j++){
Index: issm/trunk-jpl/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/AverageOntoPartitionx/AverageOntoPartitionx.cpp	(revision 18521)
@@ -41,5 +41,5 @@
 	/*loop on each element, and add contribution of the element to the partition (surface weighted average): */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->AverageOntoPartition(partition_contributions,partition_areas,vertex_response,qmu_part);
 	}
Index: issm/trunk-jpl/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/ConfigureObjectsx/ConfigureObjectsx.cpp	(revision 18521)
@@ -24,5 +24,5 @@
 	if(VerboseMProcessor()) _printf0_("      Configuring elements...\n");
 	for(i=0;i<elements->Size();i++){
-		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->Configure(elements,loads,nodes,vertices,materials,parameters);
 	}
Index: issm/trunk-jpl/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp	(revision 18521)
@@ -29,5 +29,5 @@
 	/*Create and assemble matrix*/
 	for(i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		ElementMatrix* Je = analysis->CreateJacobianMatrix(element);
 		if(Je) Je->AddToGlobal(Jff);
Index: issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=DragCoefficientAbsGradient(element);
 	}
Index: issm/trunk-jpl/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/FloatingiceMeltingRatex/FloatingiceMeltingRatex.cpp	(revision 18521)
@@ -33,5 +33,5 @@
 
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->LinearFloatingiceMeltingRate();
 	}
Index: issm/trunk-jpl/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp	(revision 18521)
@@ -32,5 +32,5 @@
 	Analysis* analysis = EnumToAnalysis(analysisenum);
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		analysis->GetSolutionFromInputs(solution,element);
 	}
Index: issm/trunk-jpl/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/GetVectorFromInputsx/GetVectorFromInputsx.cpp	(revision 18521)
@@ -19,5 +19,5 @@
 		/*Look up in elements*/
 		for(i=0;i<femmodel->elements->Size();i++){
-			Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+			Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 			element->GetVectorFromInputs(vector,name);
 		}
Index: issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/GroundinglineMigrationx/GroundinglineMigrationx.cpp	(revision 18521)
@@ -47,5 +47,5 @@
 	/*Migrate grounding line : */
 	for(int i=0;i<elements->Size();i++){
-		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->MigrateGroundingLine(phi_ungrounding);
 	}
@@ -72,5 +72,5 @@
 	/*Fill vector vertices_potentially_floating: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->FSContactMigration(vertexgrounded,vertexfloating);
 	}
@@ -120,5 +120,5 @@
 	/*Fill vector vertices_potentially_floating: */
 	for(i=0;i<elements->Size();i++){
-		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->PotentialUngrounding(vec_vertices_potentially_ungrounding);
 	}
@@ -148,5 +148,5 @@
 	vec_phi=new Vector<IssmDouble>(vertices->NumberOfVertices());
 	for(i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->GetVectorFromInputs(vec_phi,MaskGroundediceLevelsetEnum);
 	}
@@ -162,5 +162,5 @@
 		/*Figure out if any of the nodes of the element will be floating -> elements neighbouting the floating ice*/
 		for(i=0;i<elements->Size();i++){
-			element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+			element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 			vec_elements_neighboring_floatingice->SetValue(element->Sid(),element->IsNodeOnShelfFromFlags(phi)?1.0:0.0,INS_VAL);
 		}
@@ -173,5 +173,5 @@
 		local_nflipped=0;
 		for(i=0;i<elements->Size();i++){
-			element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+			element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 			if(reCast<int,IssmDouble>(elements_neighboring_floatingce[element->Sid()])){
 				local_nflipped+=element->UpdatePotentialUngrounding(vertices_potentially_ungrounding,vec_phi,phi);
Index: issm/trunk-jpl/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputControlUpdatex/InputControlUpdatex.cpp	(revision 18521)
@@ -12,5 +12,5 @@
 	/*Go through elemnets, and ask to carry out the operation on inputs: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->InputControlUpdate(scalar,save_parameter);
 	}
Index: issm/trunk-jpl/src/c/modules/InputDepthAverageAtBasex/InputDepthAverageAtBasex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputDepthAverageAtBasex/InputDepthAverageAtBasex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputDepthAverageAtBasex/InputDepthAverageAtBasex.cpp	(revision 18521)
@@ -10,5 +10,5 @@
 void InputDepthAverageAtBasex(FemModel* femmodel,int original_enum, int new_enum){
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputDepthAverageAtBase(original_enum,new_enum);
 	}
Index: issm/trunk-jpl/src/c/modules/InputDuplicatex/InputDuplicatex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputDuplicatex/InputDuplicatex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputDuplicatex/InputDuplicatex.cpp	(revision 18521)
@@ -11,5 +11,5 @@
 	/*Go through elemnets, and ask to reinitialie the input: */
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputDuplicate(original_enum,new_enum);
 	}
Index: issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputExtrudex/InputExtrudex.cpp	(revision 18521)
@@ -10,5 +10,5 @@
 void InputExtrudex(FemModel* femmodel,int input_enum,int start){
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputExtrude(input_enum,start);
 	}
Index: issm/trunk-jpl/src/c/modules/InputScalex/InputScalex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputScalex/InputScalex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputScalex/InputScalex.cpp	(revision 18521)
@@ -15,5 +15,5 @@
 	/*Go through elemnets, and ask to reinitialie the input: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->InputScale(enum_type,scale_factor);
 	}
Index: issm/trunk-jpl/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputUpdateFromConstantx/InputUpdateFromConstantx.cpp	(revision 18521)
@@ -14,5 +14,5 @@
 	/*Elements and loads drive the update: */
 	for(i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputUpdateFromConstant(constant,name);
 	}
@@ -35,5 +35,5 @@
 	/*Elements and loads drive the update: */
 	for(i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputUpdateFromConstant(constant,name);
 	}
@@ -56,5 +56,5 @@
 	/*Elements and loads drive the update: */
 	for(i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputUpdateFromConstant(constant,name);
 	}
@@ -78,5 +78,5 @@
 	/*Elements and loads drive the update: */
 	for(i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->InputUpdateFromConstant(constant,name);
 	}
Index: issm/trunk-jpl/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputUpdateFromMatrixDakotax/InputUpdateFromMatrixDakotax.cpp	(revision 18521)
@@ -20,5 +20,5 @@
 		/*Update elements, nodes, loads and materials from inputs: */
 		for(i=0;i<femmodel->elements->Size();i++){
-			Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+			Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 			element->InputUpdateFromMatrixDakota(matrix,nrows,ncols,name,type);
 		}
Index: issm/trunk-jpl/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp	(revision 18521)
@@ -30,5 +30,5 @@
 	Analysis* analysis = EnumToAnalysis(analysisenum);
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		analysis->InputUpdateFromSolution(solution,element);
 	}
Index: issm/trunk-jpl/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputUpdateFromVectorDakotax/InputUpdateFromVectorDakotax.cpp	(revision 18521)
@@ -22,5 +22,5 @@
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputUpdateFromVectorDakota(vector,name,type);
 	}
Index: issm/trunk-jpl/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/InputUpdateFromVectorx/InputUpdateFromVectorx.cpp	(revision 18521)
@@ -20,5 +20,5 @@
 	/*Update elements, nodes, loads and materials from inputs: */
 	for(i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->InputUpdateFromVector(vector,name,type);
 	}
Index: issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateOutputDefinitions.cpp	(revision 18521)
@@ -84,5 +84,5 @@
 					/*Now, for this particular misfit object, make sure we plug into the elements: the observation, and the weights.*/
 					for(i=0;i<elements->Size();i++){
-						Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+						Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 						element->InputCreate(misfit_observation_s[j], iomodel,misfit_observation_M_s[j],misfit_observation_N_s[j],1,misfit_observation_enum_s[j],7);
 						element->InputCreate(misfit_weights_s[j], iomodel,misfit_weights_M_s[j],misfit_weights_N_s[j],1,misfit_weights_enum_s[j],7);
Index: issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/NodalValuex/NodalValuex.cpp	(revision 18521)
@@ -20,5 +20,5 @@
 	 *element, figure out  if they hold the vertex, and the data. If so, return it: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		found=element->NodalValue(&value,index,natureofdataenum);
 		if(found){
Index: issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/OutputDefinitionsResponsex/OutputDefinitionsResponsex.cpp	(revision 18521)
@@ -20,5 +20,5 @@
 	for(int i=0;i<output_definitions->Size();i++){
 		
-		definition=dynamic_cast<Definition*>(output_definitions->GetObjectByOffset(i));
+		definition=xDynamicCast<Definition*>(output_definitions->GetObjectByOffset(i));
 
 		char* name = definition->Name();
Index: issm/trunk-jpl/src/c/modules/ResetFSBasalBoundaryConditionx/ResetFSBasalBoundaryConditionx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ResetFSBasalBoundaryConditionx/ResetFSBasalBoundaryConditionx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/ResetFSBasalBoundaryConditionx/ResetFSBasalBoundaryConditionx.cpp	(revision 18521)
@@ -12,5 +12,5 @@
 
 	for (int i=0;i<elements->Size();i++){
-		element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		element->ResetFSBasalBoundaryCondition();
 	}
Index: issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=RheologyBbarAbsGradient(element);
 	}
Index: issm/trunk-jpl/src/c/modules/SetActiveNodesLSMx/SetActiveNodesLSMx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SetActiveNodesLSMx/SetActiveNodesLSMx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SetActiveNodesLSMx/SetActiveNodesLSMx.cpp	(revision 18521)
@@ -22,5 +22,5 @@
 
 	for(i=0;i<elements->Size();i++){
-		Element    *element  = dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element    *element  = xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		int         numnodes = element->GetNumberOfNodes();
 		IssmDouble *mask     = xNew<IssmDouble>(numnodes);
@@ -104,5 +104,5 @@
 	/*Fill vector with values: */
 	for(i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		SetMaskOfIceElement(vec_mask_ice, element);
 	}
Index: issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=SurfaceAbsVelMisfit(element);
 	}
Index: issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SurfaceAreax/SurfaceAreax.cpp	(revision 18521)
@@ -20,5 +20,5 @@
 	/*Compute gradients: */
 	for(int i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		S+=element->SurfaceArea();
 	}
Index: issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SurfaceAverageVelMisfitx/SurfaceAverageVelMisfitx.cpp	(revision 18521)
@@ -17,5 +17,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		J+=SurfaceAverageVelMisfit(element);
 	}
Index: issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=SurfaceLogVelMisfit(element);
 	}
Index: issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=SurfaceLogVxVyMisfit(element);
 	}
Index: issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SurfaceMassBalancex/SurfaceMassBalancex.cpp	(revision 18521)
@@ -64,5 +64,5 @@
 	/*Loop over all the elements of this partition*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		/*Allocate all arrays*/
@@ -113,5 +113,5 @@
 
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->Delta18oParameterization();
 	}
@@ -204,5 +204,5 @@
 
 	for(i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		element->PositiveDegreeDay(pdds,pds,signorm);
 	}
@@ -234,5 +234,5 @@
 	/*Loop over all the elements of this partition*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		/*Get reference SMB (uncorrected) and allocate all arrays*/
@@ -292,5 +292,5 @@
 	/*Loop over all the elements of this partition*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		/*Allocate all arrays*/
@@ -333,5 +333,5 @@
 	/*Loop over all the elements of this partition*/
 	for(int i=0;i<femmodel->elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 
 		/*Allocate all arrays*/
Index: issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=SurfaceRelVelMisfit(element);
 	}
Index: issm/trunk-jpl/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/SystemMatricesx/SystemMatricesx.cpp	(revision 18521)
@@ -40,5 +40,5 @@
 		/*Get complete stiffness matrix without penalties*/
 		for (i=0;i<femmodel->elements->Size();i++){
-			element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+			element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 			ElementMatrix* Ke = analysis->CreateKMatrix(element);
 			ElementVector* pe = analysis->CreatePVector(element);
@@ -50,5 +50,5 @@
 
 		for (i=0;i<femmodel->loads->Size();i++){
-			load=dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));
+			load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i));
 			if(load->InAnalysis(configuration_type)) load->CreateKMatrix(Kff_temp,NULL);
 		}
@@ -71,5 +71,5 @@
 	/*Fill stiffness matrix and load vector from elements*/
 	for (i=0;i<femmodel->elements->Size();i++){
-		element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+		element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 		ElementMatrix* Ke = analysis->CreateKMatrix(element);
 		ElementVector* pe = analysis->CreatePVector(element);
@@ -85,5 +85,5 @@
 	/*Fill stiffness matrix and load vector from loads*/
 	for(i=0;i<femmodel->loads->Size();i++){
-		load=dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));
+		load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i));
 		if(load->InAnalysis(configuration_type)){
 			load->CreateKMatrix(Kff,Kfs);
@@ -95,5 +95,5 @@
 	if(femmodel->loads->IsPenalty(configuration_type)){
 		for (i=0;i<femmodel->loads->Size();i++){
-			load=dynamic_cast<Load*>(femmodel->loads->GetObjectByOffset(i));
+			load=xDynamicCast<Load*>(femmodel->loads->GetObjectByOffset(i));
 			if(load->InAnalysis(configuration_type)){
 				load->PenaltyCreateKMatrix(Kff,Kfs,kmax);
@@ -106,5 +106,5 @@
 	if(pdf){
 		for(i=0;i<femmodel->elements->Size();i++){
-			element=dynamic_cast<Element*>(femmodel->elements->GetObjectByOffset(i));
+			element=xDynamicCast<Element*>(femmodel->elements->GetObjectByOffset(i));
 			ElementVector* de=analysis->CreateDVector(element);
 			if(de) de->InsertIntoGlobal(df);
Index: issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=ThicknessAbsMisfit(element);
 	}
Index: issm/trunk-jpl/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=ThicknessAcrossGradient(element);
 	}
Index: issm/trunk-jpl/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp
===================================================================
--- issm/trunk-jpl/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/modules/ThicknessAlongGradientx/ThicknessAlongGradientx.cpp	(revision 18521)
@@ -16,5 +16,5 @@
 	/*Compute Misfit: */
 	for(int i=0;i<elements->Size();i++){
-		Element* element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
+		Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
 		J+=ThicknessAlongGradient(element);
 	}
Index: issm/trunk-jpl/src/c/shared/Numerics/recast.h
===================================================================
--- issm/trunk-jpl/src/c/shared/Numerics/recast.h	(revision 18520)
+++ issm/trunk-jpl/src/c/shared/Numerics/recast.h	(revision 18521)
@@ -40,3 +40,14 @@
 #endif
 
+/*Morlighem's change: we do not want dynamic_casts because of performance
+ * issue, so for now, we just use C-like cast*/
+template<class To,class From> To xDynamicCast(const From& from) {
+
+	/*C-like cast (fast but not safe)*/
+	return (To) from;
+
+	/*C++ dynamic_cast, poor performance but safer*/
+	//return dynamic_cast<To>(from);
+}
+
 #endif
Index: issm/trunk-jpl/src/c/toolkits/gsl/DenseGslSolve.cpp
===================================================================
--- issm/trunk-jpl/src/c/toolkits/gsl/DenseGslSolve.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/toolkits/gsl/DenseGslSolve.cpp	(revision 18521)
@@ -235,5 +235,5 @@
 	IssmPDouble* pdoubleEDFout=xNew<IssmPDouble>(n);           // provide space to transfer outputs during call_ext_fct
 	// call the wrapped solver through the registry entry we retrieve from parameters
-	call_ext_fct(dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,
+	call_ext_fct(xDynamicCast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,
 	             n*(n+1), pdoubleEDFin, adoubleEDFin,
 	             n, pdoubleEDFout,X);
Index: issm/trunk-jpl/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp
===================================================================
--- issm/trunk-jpl/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/toolkits/mumps/MpiDenseMumpsSolve.cpp	(revision 18521)
@@ -244,5 +244,5 @@
   IssmPDouble *passiveSol=xNew<IssmPDouble>(n);
   IssmDouble *sol=xNew<IssmDouble>(n);
-  call_ext_fct(dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,
+  call_ext_fct(xDynamicCast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,
 	       packedDimsSparseArrLength, packedDimsSparseArr,
 	       local_nnz+n, passivePack_A_rhs, pack_A_rhs, 
Index: issm/trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp
===================================================================
--- issm/trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp	(revision 18520)
+++ issm/trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp	(revision 18521)
@@ -324,5 +324,5 @@
   IssmPDouble *passiveSol=xNew<IssmPDouble>(n);
   IssmDouble *sol=xNew<IssmDouble>(n);
-  call_ext_fct(dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,
+  call_ext_fct(xDynamicCast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p,
 	       packedDimsSparseArrLength, packedDimsSparseArr,
 	       local_nnz+n, passivePack_A_rhs, pack_A_rhs, 
