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

Method addParameter

DEVELOPER/core/Domain.cpp:759–818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

757}
758
759bool
760Domain::addParameter(Parameter *theParam)
761{
762 int paramTag = theParam->getTag();
763
764 if (paramTag == 0) {
765 // don't add it .. just invoke setDomain on the parameter
766 theParam->setDomain(this);
767 return true;
768 }
769
770 // check if a Parameter with a similar tag already exists in the Domain
771 TaggedObject *other = theParameters->getComponentPtr(paramTag);
772 if (other != 0) {
773 opserr << "Domain::addParameter - parameter with tag " << paramTag << "already exists in model\n";
774 return false;
775 }
776
777 // add the param to the container object for the parameters
778 bool result = theParameters->addComponent(theParam);
779
780 if (result == false) {
781 opserr << "Domain::addParameter - parameter " << paramTag << "could not be added to container\n";
782 theParam->setDomain(this);
783 return result;
784 }
785
786 // mark the Domain as having been changed
787 // this->domainChange();
788
789 // Array is full or empty
790 if (numParameters == paramSize) {
791
792 // Increase size and allocate new array
793 paramSize += paramSize_grow;
794 int *tmp_paramIndex = new int[paramSize];
795
796 // Copy values from old array to new
797 for (int i = 0; i < numParameters; i++)
798 tmp_paramIndex[i] = paramIndex[i];
799
800 // Get rid of old array
801 delete [] paramIndex;
802
803 // Set pointer to new array
804 paramIndex = tmp_paramIndex;
805 }
806
807 // Add to index
808 paramIndex[numParameters] = paramTag;
809 theParam->setGradIndex(numParameters);
810 numParameters++;
811
812 if (strcmp(theParam->getType(),"FEModel") != 0) {
813 //theParam->setGradIndex(-1);
814 }
815
816 theParam->setDomain(this);

Callers 1

recvSelfMethod · 0.95

Calls 6

getTagMethod · 0.45
setDomainMethod · 0.45
getComponentPtrMethod · 0.45
addComponentMethod · 0.45
setGradIndexMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected