[cig-commits] r15061 - short/3D/PyLith/trunk/libsrc/materials
willic3 at geodynamics.org
willic3 at geodynamics.org
Tue May 26 15:22:08 PDT 2009
Author: willic3
Date: 2009-05-26 15:22:08 -0700 (Tue, 26 May 2009)
New Revision: 15061
Modified:
short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.cc
short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.hh
short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.cc
short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh
Log:
Made a few more changes.
Things still don't compile.
Modified: short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.cc 2009-05-26 22:12:18 UTC (rev 15060)
+++ short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.cc 2009-05-26 22:22:08 UTC (rev 15061)
@@ -27,6 +27,7 @@
double
pylith::materials::EffectiveStress::getEffStress(
const double effStressInitialGuess,
+ const double stressScale,
EffStressStruct* effStressParams,
effStressFunc_fn_type effStressFunc,
effStressFuncDFunc_fn_type effStressFuncDFunc)
@@ -42,16 +43,18 @@
x1 = effStressInitialGuess - 0.5 * effStressInitialGuess;
x2 = effStressInitialGuess + 0.5 * effStressInitialGuess;
} else {
- x1 = effStressParams.stressScale - 0.5 * effStressParams.stressScale;
- x2 = effStressParams.stressScale + 0.5 * effStressParams.stressScale;
+ x1 = stressScale - 0.5 * stressScale;
+ x2 = stressScale + 0.5 * stressScale;
} // else
PetscLogFlops(4);
_bracketEffStress(x1, x2, effStressParams, effStressFunc);
// Find effective stress using Newton's method with bisection.
- const double effStress = _findEffStress(&x1,
- &x2,
+ const double xx1 = x1;
+ const double xx2 = x2;
+ const double effStress = _findEffStress(xx1,
+ xx2,
effStressParams,
effStressFunc,
effStressFuncDFunc);
@@ -113,11 +116,11 @@
// Find root using Newton's method with bisection.
void
pylith::materials::EffectiveStress::_findEffStress(
- const double x1,
- const double x2,
- EffStressStruct& effStressParams,
- effStressFuncType* effStressFunc,
- effStressFuncDFuncType* effStressFuncDFunc)
+ const double xx1,
+ const double xx2,
+ EffStressStruct effStressParams,
+ effStressFuncType effStressFunc,
+ effStressFuncDFuncType effStressFuncDFunc)
{ // _findEffStress
// Arbitrary number of iterations to find the root
const int maxIterations = 100;
@@ -127,8 +130,8 @@
/// Determine if root has already been found, or if root is not bracketed.
// Otherwise, organize search so that effStressFunc(xLow) is less than zero.
- double funcValueLow = effStressFunc(x1, effStressParams);
- double funcValueHigh = effStressFunc(x2, effStressParams);
+ double funcValueLow = effStressFunc(xx1, effStressParams);
+ double funcValueHigh = effStressFunc(xx2, effStressParams);
if (funcValueLow * funcValueHigh > 0.0)
throw std::runtime_error("Effective stress is not bracketed.");
@@ -138,23 +141,23 @@
bool converged = false;
if (std::abs(funcValueLow) < accuracy) {
- effStress = x1;
+ effStress = xx1;
converged = true;
return effStress;
} else if (std::abs(funcValueHigh) < accuracy) {
- effStress = x2;
+ effStress = xx2;
converged = true;
return effStress;
} else if (funcValueLow < 0.0) {
- xLow = x1;
- xHigh = x2;
+ xLow = xx1;
+ xHigh = xx2;
} else {
- xHigh = x1;
- xLow = x2;
+ xHigh = xx1;
+ xLow = xx2;
}
- effStress = 0.5 * (x1 + x2);
- double dxPrevious = std::abs(x2 - x1);
+ effStress = 0.5 * (xx1 + xx2);
+ double dxPrevious = std::abs(xx2 - xx1);
double dx = dxPrevious;
double funcValue = 0.0;
double funcDeriv = 0.0;
Modified: short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.hh 2009-05-26 22:12:18 UTC (rev 15060)
+++ short/3D/PyLith/trunk/libsrc/materials/EffectiveStress.hh 2009-05-26 22:22:08 UTC (rev 15061)
@@ -37,7 +37,6 @@
public :
struct EffStressStruct {
- double stressScale;
double ae;
double b;
double c;
@@ -55,17 +54,17 @@
/// Member prototype for effStressFunc()
typedef static double (*effStressFunc_fn_type)
(const double,
- const double*);
+ EffStressStruct);
/// Member prototype for effStressDFunc()
typedef static double (*effStressDFunc_fn_type)
(const double,
- const double*);
+ EffStressStruct);
/// Member prototype for effStressFuncDFunc()
typedef static void (*effStressFuncDFunc_fn_type)
(const double,
- const double*,
+ EffStressStruct,
double*,
double*);
@@ -96,7 +95,8 @@
*/
static
double getEffStress(const double effStressInitialGuess,
- EffStressStruct* effStressParams,
+ const double stressScale,
+ EffStressStruct effStressParams,
effStressFunc_fn_type effStressFunc,
effStressFuncDFunc_fn_type effStressFuncDFunc);
@@ -113,7 +113,7 @@
*/
void _bracketEffStress(double* px1,
double* px2,
- EffStressStruct& effStressParams,
+ EffStressStruct effStressParams,
effStressFunc_fn_type effStressFunc);
/** Solve for effective stress using Newton's method with bisection.
@@ -124,12 +124,13 @@
* @param effStressFunc Function to compute effective stress only.
* @param effStressFuncDFunc Function to compute effective stress and derivative.
*
+ * @returns Computed effective stress.
*/
- void _findEffStress(double* px1,
- double* px2,
- EffStressStruct& effStressParams,
- effStressFunc_fn_type* effStressFunc,
- effStressFuncDFunc_fn_type* effStressFuncDFunc);
+ double _findEffStress(double xx1,
+ double xx2,
+ EffStressStruct effStressParams,
+ effStressFunc_fn_type effStressFunc,
+ effStressFuncDFunc_fn_type effStressFuncDFunc);
}; // class EffectiveStress
Modified: short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.cc 2009-05-26 22:12:18 UTC (rev 15060)
+++ short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.cc 2009-05-26 22:22:08 UTC (rev 15061)
@@ -589,7 +589,6 @@
PetscLogFlops(92);
// Put parameters into a struct and call root-finding algorithm.
- _effStressParams.stressScale = stressScale;
_effStressParams.ae = ae;
_effStressParams.b = b;
_effStressParams.c = c;
@@ -605,7 +604,8 @@
double effStressTpdt =
pylith::materials::EffectiveStress::getEffStress(
effStressInitialGuess,
- &_effStressParams,
+ stressScale,
+ _effStressParams,
pylith::materials::PowerLaw3D::effStressFunc,
pylith::materials::PowerLaw3D::effStressFuncDFunc);
@@ -638,6 +638,7 @@
// ----------------------------------------------------------------------
// Effective stress function that computes effective stress function only
// (no derivative).
+static
double
pylith::materials::PowerLaw3D::effStressFunc(
const double effStressTpdt,
@@ -666,6 +667,7 @@
// ----------------------------------------------------------------------
// Effective stress function that computes effective stress function
// derivative only (no function value).
+static
double
pylith::materials::PowerLaw3D::effStressDFunc(
const double effStressTpdt,
@@ -697,6 +699,7 @@
// ----------------------------------------------------------------------
// Effective stress function that computes effective stress function
// and derivative.
+static
void
pylith::materials::PowerLaw3D::effStressFuncDFunc(
const double effStressTpdt,
@@ -1010,7 +1013,6 @@
PetscLogFlops(92);
// Put parameters into a struct and call root-finding algorithm.
- _effStressParams.stressScale = stressScale;
_effStressParams.ae = ae;
_effStressParams.b = b;
_effStressParams.c = c;
@@ -1026,7 +1028,8 @@
const double effStressTpdt =
EffectiveStress::getEffStress(
effStressInitialGuess,
- &_effStressParams,
+ stressScale,
+ _effStressParams,
pylith::materials::PowerLaw3D::effStressFunc,
pylith::materials::PowerLaw3D::effStressFuncDFunc);
@@ -1333,7 +1336,6 @@
PetscLogFlops(92);
// Put parameters into a struct and call root-finding algorithm.
- _effStressParams.stressScale = stressScale;
_effStressParams.ae = ae;
_effStressParams.b = b;
_effStressParams.c = c;
@@ -1349,7 +1351,8 @@
double effStressTpdt =
EffectiveStress::getEffStress(
effStressInitialGuess,
- &_effStressParams,
+ stressScale,
+ _effStressParams,
pylith::materials::PowerLaw3D::effStressFunc,
pylith::materials::PowerLaw3D::effStressFuncDFunc);
Modified: short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh
===================================================================
--- short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh 2009-05-26 22:12:18 UTC (rev 15060)
+++ short/3D/PyLith/trunk/libsrc/materials/PowerLaw3D.hh 2009-05-26 22:22:08 UTC (rev 15061)
@@ -70,6 +70,8 @@
*
* @param effStressTpdt Effective stress value.
* @param effStressParams Effective stress parameters.
+ *
+ * @returns Effective stress function derivative value.
*/
static double effStressDFunc(
const double effStressTpdt,
More information about the CIG-COMMITS
mailing list