| 58 | } |
| 59 | |
| 60 | int |
| 61 | BackgroundFixData::tryFix(int ndtag, Domain& domain) |
| 62 | { |
| 63 | // get node |
| 64 | Node* node = domain.getNode(ndtag); |
| 65 | if (node == 0) { |
| 66 | opserr<<"WARNING: node "<<ndtag<<" not exist\n"; |
| 67 | return -1; |
| 68 | } |
| 69 | int ndf = node->getNumberDOF(); |
| 70 | |
| 71 | // crds |
| 72 | const Vector& crds = node->getCrds(); |
| 73 | |
| 74 | // check each info |
| 75 | int index = -1; |
| 76 | for (int i=0; i<(int)min.size(); i++) { |
| 77 | if (crds.Size() != min[i].Size()) { |
| 78 | opserr << "WARNING: ndm for the nodes and fix range are not compatible\n"; |
| 79 | return -1; |
| 80 | } |
| 81 | if (crds.Size() != max[i].Size()) { |
| 82 | opserr << "WARNING: ndm for the nodes and fix range are not compatible\n"; |
| 83 | return -1; |
| 84 | } |
| 85 | |
| 86 | // if in the fix area |
| 87 | bool fixed = true; |
| 88 | for (int j=0; j<crds.Size(); j++) { |
| 89 | if (crds(j)<min[i](j) || crds(j)>max[i](j)) { |
| 90 | fixed = false; |
| 91 | break; |
| 92 | } |
| 93 | } |
| 94 | if (fixed) { |
| 95 | index = i; |
| 96 | break; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // if not fixed |
| 101 | if (index == -1) return 0; |
| 102 | |
| 103 | // set nodal states |
| 104 | Vector disp = node->getTrialDisp(); |
| 105 | Vector vel = node->getTrialVel(); |
| 106 | Vector accel = node->getTrialVel(); |
| 107 | for (int i=0; i<ndf; i++) { |
| 108 | if (i>=fix[index].Size()) break; |
| 109 | if (fix[index](i) != 0) { |
| 110 | disp(i) = 0.0; |
| 111 | vel(i) = 0.0; |
| 112 | accel(i) = 0.0; |
| 113 | } |
| 114 | } |
| 115 | node->setTrialDisp(disp); |
| 116 | node->setTrialVel(vel); |
| 117 | node->setTrialAccel(accel); |
nothing calls this directly
no test coverage detected