| 757 | } |
| 758 | |
| 759 | bool |
| 760 | Domain::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); |
no test coverage detected