[cig-commits] commit: Move some construction for SurfaceProcess from AssignXML to Build so that the fields will be properly built before they are needed.

Mercurial hg at geodynamics.org
Sun Oct 23 19:28:21 PDT 2011


changeset:   899:cf8c6a5e7d07
tag:         tip
user:        Walter Landry <wlandry at caltech.edu>
date:        Sun Oct 23 19:26:43 2011 -0700
files:       plugins/SurfaceProcess/SurfaceProcess.cxx
description:
Move some construction for SurfaceProcess from AssignXML to Build so that the fields will be properly built before they are needed.


diff -r 2bcdefd04505 -r cf8c6a5e7d07 plugins/SurfaceProcess/SurfaceProcess.cxx
--- a/plugins/SurfaceProcess/SurfaceProcess.cxx	Sun Oct 23 19:25:43 2011 -0700
+++ b/plugins/SurfaceProcess/SurfaceProcess.cxx	Sun Oct 23 19:26:43 2011 -0700
@@ -186,9 +186,6 @@ void _Underworld_SurfaceProcess_AssignFr
   Codelet* sp = (Codelet*)component;
   UnderworldContext*			uwCtx;
   Underworld_SurfaceProcess_Context*	spCtx;
-  Dictionary*			spDict;
-  char*				meshName;
-  char*                         velocityName;
 
   assert( component );
   assert( cf );
@@ -216,47 +213,46 @@ void _Underworld_SurfaceProcess_AssignFr
   spCtx->timeIntegrator =
     Stg_ComponentFactory_ConstructByName( cf, (Name)"timeIntegrator",
                                           TimeIntegrator, True, data  );
-
-  /* Get the dictionary. */
-  spDict = Dictionary_GetDictionary( uwCtx->dictionary, "SurfaceProcess" );
-  if( !spDict )
-    return;
-
-  /* Read in the variables. */
-  meshName = Dictionary_GetString( spDict, "mesh" );
-  assert( meshName && strcmp( meshName, "" ) );
-  spCtx->mesh = Stg_ComponentFactory_ConstructByName( cf, meshName, Mesh, True,
-                                                      NULL );
-  velocityName = Dictionary_GetString( spDict, "VelocityField" );
-  assert( velocityName && strcmp( velocityName, "" ) );
-  spCtx->v = Stg_ComponentFactory_ConstructByName( cf, velocityName, FeVariable,
-                                                   True, NULL );
-  assert( spCtx->v);
-  spCtx->K = Dictionary_GetDouble( spDict, "diffusionCoefficient" );
 }
 
 void _Underworld_SurfaceProcess_Build( void* codelet, void* data ) {
-	Codelet* sp= (Codelet*)codelet;
-	UnderworldContext* UnderworldCtx = (UnderworldContext*)sp->context;
-	Underworld_SurfaceProcess_Context*	spCtx;
+  Codelet* sp= (Codelet*)codelet;
+  UnderworldContext* uwCtx = (UnderworldContext*)sp->context;
+  Underworld_SurfaceProcess_Context*	spCtx;
 
-	assert( codelet );
-	assert( UnderworldCtx );
+  assert( codelet );
+  assert( uwCtx );
 
-	/* Get the context. */
-	spCtx = (Underworld_SurfaceProcess_Context*)ExtensionManager_Get( UnderworldCtx->extensionMgr, UnderworldCtx, Underworld_SurfaceProcess_ContextHandle );
+  /* Get the context. */
+  spCtx = (Underworld_SurfaceProcess_Context*)
+    ExtensionManager_Get(uwCtx->extensionMgr,uwCtx,
+                         Underworld_SurfaceProcess_ContextHandle);
 
-	if( !spCtx->mesh )
-		return;
+  /* Get the dictionary. */
+  Dictionary* spDict=Dictionary_GetDictionary(uwCtx->dictionary,"SurfaceProcess");
+  Journal_Firewall(spDict!=NULL,Underworld_Error,
+                   "Could not find SurfaceProcess struct");
 
-	/* Append to the list of time integratee finish routines.  It
-           should come last, because EulerDeform will reset the
-           values. */
-	TimeIntegrator_AppendSetupEP( spCtx->timeIntegrator, 
-					"Underworld_SurfaceProcess_Execute", 
-                                      (void*)Underworld_SurfaceProcess_Execute, 
-					"SurfaceProcess", 
-					spCtx );
+  /* Read in the variables. */
+  char *meshName = Dictionary_GetString( spDict, "mesh" );
+  assert( meshName && strcmp( meshName, "" ) );
+  spCtx->mesh=
+    Stg_ComponentFactory_ConstructByName(uwCtx->CF,meshName,Mesh,True,NULL);
+  char *velocityName = Dictionary_GetString( spDict, "VelocityField" );
+  assert( velocityName && strcmp( velocityName, "" ) );
+  spCtx->v=Stg_ComponentFactory_ConstructByName(uwCtx->CF,velocityName,
+                                                FeVariable,True,NULL);
+  assert( spCtx->v);
+  spCtx->K = Dictionary_GetDouble( spDict, "diffusionCoefficient" );
+
+  /* Append to the list of time integratee finish routines.  It
+     should come last, because EulerDeform will reset the
+     values. */
+  TimeIntegrator_AppendSetupEP( spCtx->timeIntegrator, 
+                                "Underworld_SurfaceProcess_Execute", 
+                                (void*)Underworld_SurfaceProcess_Execute, 
+                                "SurfaceProcess", 
+                                spCtx );
 }
 
 void _Underworld_SurfaceProcess_Destroy( void* codelet, void* data ) {



More information about the CIG-COMMITS mailing list