[cig-commits] commit: Add 'equation' as a variable condition
Mercurial
hg at geodynamics.org
Wed Nov 9 00:49:34 PST 2011
changeset: 817:5abad61cd058
tag: tip
user: Walter Landry <wlandry at caltech.edu>
date: Wed Nov 09 00:49:23 2011 -0800
files: Base/Context/src/SetVC.cxx Base/Context/src/VariableAllVC.cxx Base/Context/src/VariableCondition.cxx Base/Context/src/VariableCondition.h Base/Context/src/types.h
description:
Add 'equation' as a variable condition
diff -r 6028489d7d69 -r 5abad61cd058 Base/Context/src/SetVC.cxx
--- a/Base/Context/src/SetVC.cxx Wed Nov 02 16:46:43 2011 -0700
+++ b/Base/Context/src/SetVC.cxx Wed Nov 09 00:49:23 2011 -0800
@@ -181,13 +181,21 @@ void _SetVC_ReadDictionary( void* setVC,
valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember( varDictListVal, (Dictionary_Entry_Key)"type") );
- if (!strcasecmp(valType, "func")) {
+ if (strlen(valType)==0 || 0==strcasecmp(valType, "equation"))
+ {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Equation;
+ /* This leaks memory */
+ self->_entryTbl[entry_I].value.as.equation=
+ StG_Strdup(Dictionary_Entry_Value_AsString(valueEntry));
+ }
+ else if (0 == strcasecmp(valType, "func"))
+ {
char* funcName = Dictionary_Entry_Value_AsString(valueEntry);
self->_entryTbl[entry_I].value.type = VC_ValueType_CFIndex;
self->_entryTbl[entry_I].value.as.typeCFIndex = ConditionFunction_Register_GetIndex(
self->conFunc_Register, funcName);
- }
+ }
else if (!strcasecmp(valType, "array")) {
Dictionary_Entry_Value* valueElement;
Index i;
@@ -224,11 +232,8 @@ void _SetVC_ReadDictionary( void* setVC,
self->_entryTbl[entry_I].value.as.typePtr = (void*) ((ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry ));
}
else {
- /* Assume double */
- Journal_DPrintf( Journal_Register( InfoStream_Type, (Name)"myStream" ),
- "Type to variable on variable condition not given, assuming double\n" );
- self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
- self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
+ Journal_Firewall(False,Journal_Register( Error_Type,SetVC_Type),
+ "Unknown type for variable condition: %s\n",valType);
}
}
}
@@ -323,6 +328,10 @@ void _SetVC_Print(void* setVC, Stream* s
Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_CFIndex\n");
Journal_Printf( info, "\t\t\t\tasCFIndex: %u\n", self->_entryTbl[entry_I].value.as.typeCFIndex);
break;
+ case VC_ValueType_Equation:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Equation\n");
+ Journal_Printf( info, "\t\t\t\tasEquation: %s\n", self->_entryTbl[entry_I].value.as.equation);
+ break;
}
}
diff -r 6028489d7d69 -r 5abad61cd058 Base/Context/src/VariableAllVC.cxx
--- a/Base/Context/src/VariableAllVC.cxx Wed Nov 02 16:46:43 2011 -0700
+++ b/Base/Context/src/VariableAllVC.cxx Wed Nov 09 00:49:23 2011 -0800
@@ -179,7 +179,14 @@ void _VariableAllVC_ReadDictionary( void
Dictionary_Entry_Value_GetMember( varDictListVal, (Dictionary_Entry_Key)"name") );
valType = Dictionary_Entry_Value_AsString(Dictionary_Entry_Value_GetMember( varDictListVal, (Dictionary_Entry_Key)"type") );
- if (!strcasecmp(valType, "func"))
+ if (strlen(valType)==0 || 0==strcasecmp(valType, "equation"))
+ {
+ self->_entryTbl[entry_I].value.type = VC_ValueType_Equation;
+ /* This leaks memory */
+ self->_entryTbl[entry_I].value.as.equation=
+ StG_Strdup(Dictionary_Entry_Value_AsString(valueEntry));
+ }
+ else if (0 == strcasecmp(valType, "func"))
{
char* funcName = Dictionary_Entry_Value_AsString(valueEntry);
@@ -225,10 +232,8 @@ void _VariableAllVC_ReadDictionary( void
self->_entryTbl[entry_I].value.as.typePtr = (void*) ( (ArithPointer) Dictionary_Entry_Value_AsUnsignedInt( valueEntry ));
}
else {
- /* Assume double */
- Journal_DPrintf( Journal_Register( InfoStream_Type, (Name)"myStream" ), "Type to variable on variable condition not given, assuming double\n" );
- self->_entryTbl[entry_I].value.type = VC_ValueType_Double;
- self->_entryTbl[entry_I].value.as.typeDouble = Dictionary_Entry_Value_AsDouble( valueEntry );
+ Journal_Firewall(False,Journal_Register(Error_Type,VariableAllVC_Type),
+ "Unknown type for variable condition: %s\n",valType);
}
}
}
@@ -328,6 +333,10 @@ void _VariableAllVC_Print( void* allElem
Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_CFIndex\n");
Journal_Printf( info, "\t\t\t\tasCFIndex: %u\n", self->_entryTbl[entry_I].value.as.typeCFIndex);
break;
+ case VC_ValueType_Equation:
+ Journal_Printf( info, "\t\t\t\ttype: VC_ValueType_Equation\n");
+ Journal_Printf( info, "\t\t\t\tasEquation: %s\n", self->_entryTbl[entry_I].value.as.equation);
+ break;
}
}
}
diff -r 6028489d7d69 -r 5abad61cd058 Base/Context/src/VariableCondition.cxx
--- a/Base/Context/src/VariableCondition.cxx Wed Nov 02 16:46:43 2011 -0700
+++ b/Base/Context/src/VariableCondition.cxx Wed Nov 09 00:49:23 2011 -0800
@@ -40,6 +40,10 @@
#include "ConditionFunction.h"
#include "ConditionFunction_Register.h"
#include "VariableCondition.h"
+
+#include <StGermain/StGermain.h>
+#include <StgDomain/StgDomain.h>
+#include <StgFEM/StgFEM.h>
#include <string.h>
#include <assert.h>
@@ -203,6 +207,10 @@ void _VariableCondition_Print(void* vari
case VC_ValueType_CFIndex:
Journal_Printf( variableConditionStream, "\t\t\ttype: VC_ValueType_CFIndex\n");
Journal_Printf( variableConditionStream, "\t\t\tasCFIndex: %u\n", self->valueTbl[val_I].as.typeCFIndex);
+ break;
+ case VC_ValueType_Equation:
+ Journal_Printf( variableConditionStream, "\t\t\t\ttype: VC_ValueType_Equation\n");
+ Journal_Printf( variableConditionStream, "\t\t\t\tasEquation: %s\n", self->valueTbl[val_I].as.equation);
break;
}
}
@@ -447,6 +455,20 @@ void VariableCondition_ApplyToIndex( voi
switch (self->valueTbl[val_I].type)
{
+ case VC_ValueType_Equation:
+ {
+ FeVariable *feVariable=(FeVariable*)FieldVariable_Register_GetByName
+ (((FiniteElementContext*)context)->fieldVariable_Register, "VelocityField");
+ FeMesh* mesh=feVariable->feMesh;
+ assert( mesh != NULL );
+ double* coord = Mesh_GetVertex( mesh, self->indexTbl[index] );
+ Variable_SetValueDouble(var,
+ self->indexTbl[index],
+ Equation_eval(coord,(DomainContext*)context,
+ self->valueTbl[val_I].as.equation));
+ }
+ break;
+
case VC_ValueType_Double:
Journal_Firewall( var->dataTypeCounts[0] == 1, errorStr,
"Error - in %s: while applying values for variable condition "
diff -r 6028489d7d69 -r 5abad61cd058 Base/Context/src/VariableCondition.h
--- a/Base/Context/src/VariableCondition.h Wed Nov 02 16:46:43 2011 -0700
+++ b/Base/Context/src/VariableCondition.h Wed Nov 09 00:49:23 2011 -0800
@@ -67,6 +67,7 @@
void* typePtr;
VariableCondition_Value_Array typeArray;
ConditionFunction_Index typeCFIndex;
+ char* equation;
} VariableCondition_Value_AsType;
#define __VariableCondition_Value \
diff -r 6028489d7d69 -r 5abad61cd058 Base/Context/src/types.h
--- a/Base/Context/src/types.h Wed Nov 02 16:46:43 2011 -0700
+++ b/Base/Context/src/types.h Wed Nov 09 00:49:23 2011 -0800
@@ -76,7 +76,8 @@
VC_ValueType_Char,
VC_ValueType_Ptr,
VC_ValueType_DoubleArray,
- VC_ValueType_CFIndex
+ VC_ValueType_CFIndex,
+ VC_ValueType_Equation
} VariableCondition_ValueType;
typedef Index VariableCondition_Index;
More information about the CIG-COMMITS
mailing list