[cig-commits] commit: Remove EulerDeform_InterpVar since it is not used. Make MeshAdvectionCorrection work with EulerDeform. Change the name of the displacement field to 'DisplacementField'

Mercurial hg at geodynamics.org
Sat Nov 19 10:26:24 PST 2011


changeset:   914:923496413a9f
tag:         tip
user:        Walter Landry <wlandry at caltech.edu>
date:        Sat Nov 19 10:26:07 2011 -0800
files:       plugins/EulerDeform/EulerDeform.cxx plugins/MeshAdvectionCorrection/MeshAdvectionCorrection.cxx
description:
Remove EulerDeform_InterpVar since it is not used.  Make MeshAdvectionCorrection work with EulerDeform.  Change the name of the displacement field to 'DisplacementField'


diff -r 538b08689df1 -r 923496413a9f plugins/EulerDeform/EulerDeform.cxx
--- a/plugins/EulerDeform/EulerDeform.cxx	Sat Nov 19 10:24:26 2011 -0800
+++ b/plugins/EulerDeform/EulerDeform.cxx	Sat Nov 19 10:26:07 2011 -0800
@@ -99,8 +99,6 @@ void _Underworld_EulerDeform_AssignFromX
 	/* Get the time integrator. */
 	edCtx->timeIntegrator = Stg_ComponentFactory_ConstructByName( cf, (Name)"timeIntegrator", TimeIntegrator, True, data  );
 
-	/* Grab the ArtDisplacementField from the dictionary */
-	edCtx->artDField = Stg_ComponentFactory_ConstructByName( cf, (Name)"ArtDisplacementField", FeVariable, False, data  );
 }
 
 
@@ -125,6 +123,9 @@ void _Underworld_EulerDeform_Build( void
 	if( !edDict  ) {
 		return;
 	}
+
+	/* Grab the ArtDisplacementField from the dictionary */
+	edCtx->artDField = Stg_ComponentFactory_ConstructByName( uwCtx->CF, (Name)"DisplacementField", FeVariable, False, data  );
 
 	/* Read system list. */
 	sysLst = Dictionary_Entry_Value_GetMember( edDict, (Dictionary_Entry_Key)"systems" );
@@ -1000,42 +1001,6 @@ void EulerDeform_Remesh( TimeIntegrand* 
 }
 
 
-void EulerDeform_InterpVar( FieldVariable* field, Variable* var, Mesh* mesh, double** newCrds ) {
-	double*		newVals;
-	unsigned	curValInd = 0;
-	unsigned	nLocalNodes;
-	unsigned	n_i, c_i;
-
-	assert( field );
-	/*assert( var );*/
-	assert( newCrds );
-
-	/* Allocate for new values. */
-	nLocalNodes = Mesh_GetLocalSize( mesh, MT_VERTEX );
-	newVals = Memory_Alloc_Array( double, field->fieldComponentCount * nLocalNodes, "EulerDeform_InterpVar::newVals" );
-
-	/* Interpolate using new node coordinates. */
-	for( n_i = 0; n_i < nLocalNodes; n_i++ ) {
-		InterpolationResult	res;
-
-		/* Interpolate the value. */
-		res = FieldVariable_InterpolateValueAt( field, newCrds[n_i], newVals + n_i * field->fieldComponentCount );
-		if( res == OTHER_PROC || res == OUTSIDE_GLOBAL ) {
-			FeVariable_GetValueAtNode( (FeVariable*)field, n_i, 
-						   newVals + n_i * field->fieldComponentCount );
-		}
-	}
-
-	/* Transfer the new values back to the variable. */
-	for( n_i = 0; n_i < nLocalNodes; n_i++ ) {
-	   for( c_i = 0; c_i < field->fieldComponentCount; c_i++ )
-	      DofLayout_SetValueDouble( ((FeVariable*)field)->dofLayout, n_i, c_i, newVals[curValInd++] );
-	}
-
-	/* Free the values array. */
-	FreeArray( newVals );
-}
-
 void EulerDeform_InternalLoop( EulerDeform_System* sys, Grid* grm, double** oldCrds, unsigned* ijk, unsigned curDim, int top );
 
 void EulerDeform_WrapSurface( EulerDeform_System* sys, double** oldCrds, int top ) {
diff -r 538b08689df1 -r 923496413a9f plugins/MeshAdvectionCorrection/MeshAdvectionCorrection.cxx
--- a/plugins/MeshAdvectionCorrection/MeshAdvectionCorrection.cxx	Sat Nov 19 10:24:26 2011 -0800
+++ b/plugins/MeshAdvectionCorrection/MeshAdvectionCorrection.cxx	Sat Nov 19 10:26:07 2011 -0800
@@ -119,36 +119,38 @@ void MeshAdvectionCorrection_StoreCurren
 	}
 }
 
-void MeshAdvectionCorrection_EulerDeformCorrection( FeVariable *artDField, double *artVelocity, double dt ) {
-	/* save the purely artificial bit of the remeshing in the artVelocity */
-	FeMesh*      mesh = artDField->feMesh;
-	Dof_Index    dof  = artDField->fieldComponentCount;
-	double       artV[3], artD[3];
-	unsigned int numLocalNodes = FeMesh_GetNodeLocalSize( mesh );
-	Dof_Index    dof_I, lNode_I;
+void MeshAdvectionCorrection_EulerDeformCorrection(FeVariable *artDField,
+                                                   double *artVelocity,
+                                                   double dt)
+{
+  /* save the purely artificial bit of the remeshing in the artVelocity */
+  FeMesh*      mesh = artDField->feMesh;
+  Dof_Index    dof  = artDField->fieldComponentCount;
+  double       artV[3], artD[3];
+  unsigned int numLocalNodes = FeMesh_GetNodeLocalSize( mesh );
+  Dof_Index    dof_I, lNode_I;
 
-		/* INITIAL CONDITION: artV = 0 */
-	if( dt == 0 ) {
-		for( lNode_I = 0 ; lNode_I < numLocalNodes ; lNode_I++ ) {
-			for( dof_I = 0 ; dof_I < dof ; dof_I++ ) 
-				artV[dof_I] = 0;
+  /* INITIAL CONDITION: artV = 0 */
+  if( dt == 0 ) {
+    for( lNode_I = 0 ; lNode_I < numLocalNodes ; lNode_I++ ) {
+      for( dof_I = 0 ; dof_I < dof ; dof_I++ ) 
+        artV[dof_I] = 0;
 
-			memcpy( &artVelocity[lNode_I*dof] , artV, dof*sizeof(double) );
-		}
-		return;
-	}
+      memcpy( &artVelocity[lNode_I*dof] , artV, dof*sizeof(double) );
+    }
+    return;
+  }
 	
-	 /* GENERAL algorithm artV = -1*artD / dt. It's -ve because we 
-		* want to reverse the effects of the artificial displacement */
-	for( lNode_I = 0 ; lNode_I < numLocalNodes ; lNode_I++ ) {
-		FeVariable_GetValueAtNode( artDField, lNode_I, artD );
-		/* artV = artD / dt */
-		for( dof_I = 0 ; dof_I < dof ; dof_I++ ) 
-			artV[dof_I] = -1*artD[dof_I] / dt;
+  /* GENERAL algorithm artV = -1*artD / dt. It's -ve because we 
+   * want to reverse the effects of the artificial displacement */
+  for( lNode_I = 0 ; lNode_I < numLocalNodes ; lNode_I++ ) {
+    FeVariable_GetValueAtNode( artDField, lNode_I, artD );
+    /* artV = artD / dt */
+    for( dof_I = 0 ; dof_I < dof ; dof_I++ ) 
+      artV[dof_I] = -1*artD[dof_I] / dt;
 
-		memcpy( &artVelocity[lNode_I*dof] , artV, dof*sizeof(double) );
-	}
-
+    memcpy( &artVelocity[lNode_I*dof] , artV, dof*sizeof(double) );
+  }
 }
 
 void MeshAdvectionCorrection( void* sle, void* data ) {
@@ -196,36 +198,63 @@ void MeshAdvectionCorrection( void* sle,
 	Memory_Free( oldVelocity );
 }
 
-void _Underworld_MeshAdvectionCorrection_AssignFromXML( void* component, Stg_ComponentFactory* cf, void* data ) {
-	UnderworldContext*                                      context = 
-	Stg_ComponentFactory_ConstructByName( cf, (Name)"context", UnderworldContext, True, data ); 
-	Underworld_MeshAdvectionCorrection_ContextExt*       plugin;
-   AdvectionDiffusionSLE* energySLE = (AdvectionDiffusionSLE* ) Stg_ComponentFactory_ConstructByName( cf, (Name)"EnergyEqn", UnderworldContext, True, data );
+void _Underworld_MeshAdvectionCorrection_AssignFromXML(void* component,
+                                                       Stg_ComponentFactory* cf,
+                                                       void* data)
+{
+  Codelet* ed=(Codelet*)component;
+  UnderworldContext* context=
+    Stg_ComponentFactory_ConstructByName(cf,(Name)"context",UnderworldContext,
+                                         True,data);
+  ed->context=(AbstractContext*)context;
 	
-	Journal_DFirewall( 
-		context!=NULL, 
-		Journal_Register( Error_Type, (Name)Underworld_MeshAdvectionCorrection_Type  ), 
-		"No context found\n" );
-	Journal_DFirewall( 
-		energySLE!=NULL, 
-		Journal_Register( Error_Type, (Name)Underworld_MeshAdvectionCorrection_Type  ), 
-		"The required energy SLE component has not been created or placed on the context.\n");	
+  Journal_DFirewall
+    (context!=NULL,
+     Journal_Register(Error_Type,
+                      (Name)Underworld_MeshAdvectionCorrection_Type),
+     "No context found\n");
 	
-	/* Add the extension to the context */
-	Underworld_MeshAdvectionCorrection_ContextExtHandle = ExtensionManager_Add( context->extensionMgr, (Name)Underworld_MeshAdvectionCorrection_Type, sizeof( Underworld_MeshAdvectionCorrection_ContextExt )  );
-	plugin = (Underworld_MeshAdvectionCorrection_ContextExt*)ExtensionManager_Get( 
-		context->extensionMgr, 
-		context, 
-		Underworld_MeshAdvectionCorrection_ContextExtHandle );
+  /* Add the extension to the context */
+  Underworld_MeshAdvectionCorrection_ContextExtHandle=
+    ExtensionManager_Add(context->extensionMgr,
+                         (Name)Underworld_MeshAdvectionCorrection_Type,
+                         sizeof(Underworld_MeshAdvectionCorrection_ContextExt));
+}
 
-	if( Stg_ComponentFactory_GetRootDictBool( cf, (Dictionary_Entry_Key)"MeshAdvectionCorrection_UseArtDisplacementField", False)  ) {
-		/* get the artificial displacement field */
-		plugin->artDisplacement = Stg_ComponentFactory_ConstructByName( cf, (Name)"ArtDisplacementField", FeVariable, True, data );
-	}
+void _Underworld_MeshAdvectionCorrection_Build(void* component, void* data)
+{
+  Codelet* ed=(Codelet*)component;
+  UnderworldContext* uwCtx=(UnderworldContext*)(ed->context);
 
-	/* Replace the energy SLE's execute with this one. Save the old value for use later. */
-	plugin->energySolverExecute = energySLE->_execute;
-	energySLE->_execute = MeshAdvectionCorrection;
+  assert(component);
+  assert(uwCtx);
+
+  Underworld_MeshAdvectionCorrection_ContextExt* plugin=
+    (Underworld_MeshAdvectionCorrection_ContextExt*)
+    ExtensionManager_Get(uwCtx->extensionMgr,uwCtx,
+                         Underworld_MeshAdvectionCorrection_ContextExtHandle);
+
+  AdvectionDiffusionSLE* energySLE=(AdvectionDiffusionSLE*)
+    Stg_ComponentFactory_ConstructByName(uwCtx->CF,(Name)"EnergyEqn",
+                                         AdvectionDiffusionSLE,True,data);
+	
+  Journal_DFirewall
+    (energySLE!=NULL, 
+     Journal_Register(Error_Type,
+                      (Name)Underworld_MeshAdvectionCorrection_Type),
+     "The required energy SLE component has not been created or placed"
+     "on the context.\n");
+
+  /* Replace the energy SLE's execute with this one. Save the old
+     value for use later. */
+  plugin->energySolverExecute = energySLE->_execute;
+  energySLE->_execute = MeshAdvectionCorrection;
+
+  /* Grab the ArtDisplacementField from the dictionary */
+  plugin->artDisplacement=
+    Stg_ComponentFactory_ConstructByName(uwCtx->CF,
+                                         (Name)"DisplacementField",FeVariable,
+                                         False,data);
 }
 
 /* This function will provide StGermain the abilty to instantiate (create) this codelet on demand. */
@@ -234,7 +263,7 @@ void* _Underworld_MeshAdvectionCorrectio
 			Underworld_MeshAdvectionCorrection_Type,
 			_Underworld_MeshAdvectionCorrection_DefaultNew,
 			_Underworld_MeshAdvectionCorrection_AssignFromXML, /* SQ NOTE: Used to be a construct extensions. */
-			_Codelet_Build,
+			_Underworld_MeshAdvectionCorrection_Build,
 			_Codelet_Initialise,
 			_Codelet_Execute,
 			_Codelet_Destroy,



More information about the CIG-COMMITS mailing list