MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / OPS_gradientEvaluator

Function OPS_gradientEvaluator

SRC/interpreter/OpenSeesReliabilityCommands.cpp:2644–2730  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2642}
2643
2644int OPS_gradientEvaluator() {
2645 if (OPS_GetNumRemainingInputArgs() < 1) {
2646 opserr << "ERROR: wrong number of arguments to "
2647 "gradientEvaluator"
2648 << endln;
2649 return -1;
2650 }
2651
2652 GradientEvaluator *theEval = 0;
2653
2654 // Get the type of gradientEvaluator
2655 const char *type = OPS_GetString();
2656 if (strcmp(type, "FiniteDifference") == 0) {
2657 double perturbationFactor = 1000.0;
2658 // bool doGradientCheck = false;
2659 while (OPS_GetNumRemainingInputArgs() > 0) {
2660 const char *arg = OPS_GetString();
2661 int numdata = 1;
2662 if (strcmp(arg, "-pert") == 0 &&
2663 OPS_GetNumRemainingInputArgs() > 0) {
2664 if (OPS_GetDoubleInput(&numdata, &perturbationFactor) <
2665 0) {
2666 opserr << "ERROR: unable to read -pert value for "
2667 << type << " gradient evaluator" << endln;
2668 return -1;
2669 }
2670 }
2671 if (strcmp(arg, "-check") == 0) {
2672 // doGradientCheck = true;
2673 }
2674 }
2675
2676 ReliabilityDomain *theRelDomain = cmds->getDomain();
2677 Domain *theStrDomain = cmds->getStructuralDomain();
2678 FunctionEvaluator *theEvaluator = cmds->getFunctionEvaluator();
2679 if (theEvaluator == 0) {
2680 opserr << "Function evaluator must be defined before "
2681 "gradient evaluator"
2682 << endln;
2683 return -1;
2684 }
2685
2686 theEval = new FiniteDifferenceGradient(theEvaluator, theRelDomain,
2687 theStrDomain);
2688 } else if (strcmp(type, "OpenSees") == 0 ||
2689 strcmp(type, "Implicit") == 0) {
2690 // bool doGradientCheck = false;
2691 while (OPS_GetNumRemainingInputArgs() > 0) {
2692 const char *arg = OPS_GetString();
2693 if (strcmp(arg, "-check") == 0) {
2694 // doGradientCheck = true;
2695 }
2696 }
2697
2698 ReliabilityDomain *theRelDomain = cmds->getDomain();
2699 Domain *theStrDomain = cmds->getStructuralDomain();
2700 FunctionEvaluator *theEvaluator = cmds->getFunctionEvaluator();
2701 if (theEvaluator == 0) {

Callers 2

Py_ops_gradientEvaluatorFunction · 0.85

Calls 8

getStructuralDomainMethod · 0.80
getFunctionEvaluatorMethod · 0.80
setGradientEvaluatorMethod · 0.80
OPS_GetStringFunction · 0.70
OPS_GetDoubleInputFunction · 0.70
getDomainMethod · 0.45

Tested by

no test coverage detected