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

Function OPS_Parameter

SRC/interpreter/OpenSeesParameterCommands.cpp:50–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48#endif
49
50int OPS_Parameter() {
51 Domain *theDomain = OPS_GetDomain();
52 #ifdef _RELIABILITY
53 ReliabilityDomain *theReliabilityDomain = OPS_GetReliabilityDomain();
54 #endif
55 if (theDomain == 0) return -1;
56
57 // check at least two arguments so don't segment fault on strcmp
58 if (OPS_GetNumRemainingInputArgs() < 1) {
59 opserr << "WARNING need to specify a parameter tag\n";
60 opserr << "Want: parameter tag <specific parameter args> .. see "
61 "manual for valid parameter types and arguments\n";
62 return -1;
63 }
64
65 // Figure out which parameter we are dealing with
66 int paramTag;
67 int num = 1;
68 if (OPS_GetIntInput(&num, &paramTag) < 0) {
69 opserr << "WARNING: parameter - failed to get parameter tag\n";
70 return -1;
71 }
72
73 // check existence
74 Parameter *theParameter = theDomain->getParameter(paramTag);
75 if (theParameter != 0) {
76 opserr << "WARNNG: parameter " << paramTag << " already exists\n";
77 return -1;
78 }
79
80 // First, check special case of a blank parameter
81 if (OPS_GetNumRemainingInputArgs() == 0) {
82 Parameter *newParameter = new Parameter(paramTag, 0, 0, 0);
83
84 if (theDomain->addParameter(newParameter) == false) {
85 opserr << "WARNING: failed to add parameter\n";
86 return -1;
87 }
88
89 if (OPS_SetIntOutput(&num, &paramTag, true) < 0) {
90 opserr << "WARNING: parameter - failed to set parameter tag\n";
91 return -1;
92 }
93
94 return 0;
95 }
96
97 // Second, check special case of one parameter
98 if (OPS_GetNumRemainingInputArgs() == 1) {
99 Parameter *newParameter = new Parameter(paramTag, 0, 0, 0);
100
101 double value;
102 if (OPS_GetDoubleInput(&num, &value) < 0) {
103 opserr << "WARNING: failed to get paramber value\n";
104 return -1;
105 }
106
107 newParameter->setValue(value);

Callers 2

Tcl_ops_parameterFunction · 0.85
Py_ops_parameterFunction · 0.85

Calls 15

getRandomVariablePtrMethod · 0.80
push_backMethod · 0.80
OPS_GetDomainFunction · 0.70
OPS_GetReliabilityDomainFunction · 0.70
OPS_GetIntInputFunction · 0.70
OPS_SetIntOutputFunction · 0.70
OPS_GetDoubleInputFunction · 0.70
OPS_GetStringFunction · 0.70
OPS_ResetCurrentInputArgFunction · 0.70
OPS_GetStringFromAllFunction · 0.70
getParameterMethod · 0.45

Tested by

no test coverage detected