| 2642 | } |
| 2643 | |
| 2644 | int 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) { |
no test coverage detected