[cig-commits] commit: Make StressBC and DivergenceForce use equation
Mercurial
hg at geodynamics.org
Wed Nov 9 00:58:16 PST 2011
changeset: 909:1a2bed9b406a
user: Walter Landry <wlandry at caltech.edu>
date: Wed Nov 09 00:57:57 2011 -0800
files: Utils/src/DivergenceForce.cxx Utils/src/StressBC.cxx Utils/src/types.h
description:
Make StressBC and DivergenceForce use equation
diff -r 1dbdf9f8f187 -r 1a2bed9b406a Utils/src/DivergenceForce.cxx
--- a/Utils/src/DivergenceForce.cxx Wed Nov 02 15:54:44 2011 -0700
+++ b/Utils/src/DivergenceForce.cxx Wed Nov 09 00:57:57 2011 -0800
@@ -167,13 +167,22 @@ void _DivergenceForce_AssignFromXML( voi
_ForceTerm_AssignFromXML( self, cf, data );
domainShape = Stg_ComponentFactory_ConstructByKey( cf, self->name, "DomainShape", Stg_Shape, True, data ) ;
- type = Stg_ComponentFactory_GetString( cf, self->name, "force_type", "");
+ type = Stg_ComponentFactory_GetString(cf, self->name, "force_type",
+ "equation");
if(!strcasecmp(type,"double") || !strcasecmp(type,"float"))
{
force.type = StressBC_Double;
force.DoubleValue =
Stg_ComponentFactory_GetDouble( cf, self->name, "force_value", 0.0);
+ }
+ else if (strlen(type)==0 || 0==strcasecmp(type, "equation"))
+ {
+ force.type = StressBC_Equation;
+ /* This leaks memory */
+ force.equation =
+ StG_Strdup(Stg_ComponentFactory_GetString(cf,self->name,
+ "force_value",""));
}
else if(!strcasecmp(type,"func"))
{
@@ -199,19 +208,11 @@ void _DivergenceForce_AssignFromXML( voi
}
force.CFIndex = cfIndex;
}
- else if(strlen(type)==0)
- {
- Stream* errorStr = Journal_Register( Error_Type, self->type );
- Journal_Printf( errorStr, "Error- in %s: While parsing "
- "definition of DivergenceForce, force_type is not specified.\nSupported types are \"double\" and \"func\".\n",
- __func__);
- assert(0);
- }
else
{
Stream* errorStr = Journal_Register( Error_Type, self->type );
Journal_Printf( errorStr, "Error- in %s: While parsing "
- "definition of DivergenceForce, the type of condition \"%s\"\nis not supported. Supported types are \"double\" and \"func\".\n",
+ "definition of DivergenceForce, the type of condition \"%s\"\nis not supported. Supported types are \"equation\", \"double\" and \"func\".\n",
__func__, type );
assert(0);
}
@@ -283,6 +284,11 @@ void _DivergenceForce_AssembleElement( v
case StressBC_Double:
force=self->force.DoubleValue;
break;
+ case StressBC_Equation:
+ force=Equation_eval(global_coord,
+ (DomainContext*)(self->context),
+ self->force.equation);
+ break;
case StressBC_ConditionFunction:
ConditionFunction_Apply
diff -r 1dbdf9f8f187 -r 1a2bed9b406a Utils/src/StressBC.cxx
--- a/Utils/src/StressBC.cxx Wed Nov 02 15:54:44 2011 -0700
+++ b/Utils/src/StressBC.cxx Wed Nov 09 00:57:57 2011 -0800
@@ -232,7 +232,8 @@ namespace {
}
std::string temp_str(direction + std::string("_type"));
- type=Stg_ComponentFactory_GetString( cf, self->name, temp_str.c_str(), "");
+ type=Stg_ComponentFactory_GetString(cf,self->name,temp_str.c_str(),
+ "equation");
temp_str=direction+std::string("_value");
if(!strcasecmp(type,"double") || !strcasecmp(type,"float"))
@@ -241,6 +242,19 @@ namespace {
self->_entryTbl[self->numEntries].DoubleValue =
Stg_ComponentFactory_GetDouble( cf, self->name, temp_str.c_str(), 0.0);
(self->numEntries)++;
+ }
+ else if (strlen(type)==0 || 0==strcasecmp(type, "equation"))
+ {
+ char *equation=Stg_ComponentFactory_GetString(cf,self->name,
+ temp_str.c_str(),"");
+ if(strlen(equation)!=0)
+ {
+ self->_entryTbl[self->numEntries].type = StressBC_Equation;
+ /* This leaks memory */
+ self->_entryTbl[self->numEntries].equation =
+ StG_Strdup(equation);
+ (self->numEntries)++;
+ }
}
else if(!strcasecmp(type,"func"))
{
@@ -271,7 +285,7 @@ namespace {
{
Stream* errorStr = Journal_Register( Error_Type, self->type );
Journal_Firewall( 0, errorStr, "Error- in %s: While parsing "
- "definition of StressBC (applies to wall \"%s\"), the type of condition \"%s\"\nis not supported. Supported types are \"double\" and \"function\".",
+ "definition of StressBC (applies to wall \"%s\"), the type of condition \"%s\"\nis not supported. Supported types are \"equation\", \"double\" and \"func\".",
__func__, WallEnumToStr[self->_wall],
type );
}
@@ -413,6 +427,11 @@ void _StressBC_AssembleElement( void* fo
case StressBC_Double:
stress=self->_entryTbl[entry_I].DoubleValue;
break;
+ case StressBC_Equation:
+ stress=Equation_eval(global_coord,
+ (DomainContext*)(self->context),
+ self->_entryTbl[entry_I].equation);
+ break;
case StressBC_ConditionFunction:
cf=self->conFunc_Register->
_cf[self->_entryTbl[entry_I].CFIndex];
diff -r 1dbdf9f8f187 -r 1a2bed9b406a Utils/src/types.h
--- a/Utils/src/types.h Wed Nov 02 15:54:44 2011 -0700
+++ b/Utils/src/types.h Wed Nov 09 00:57:57 2011 -0800
@@ -62,6 +62,7 @@ typedef enum
typedef enum
{
StressBC_Double,
+ StressBC_Equation,
StressBC_ConditionFunction,
StressBC_HydrostaticTerm
} StressBC_Types;
@@ -73,6 +74,7 @@ typedef struct
Index CFIndex;
unsigned int direction;
HydrostaticTerm *hydrostaticTerm;
+ char *equation;
} StressBC_Entry;
/* Wall types */
More information about the CIG-COMMITS
mailing list