int MultilevelHexahedronSetTopologyContainer::getHexaChildren(const unsigned int hexaId, helper::vector<unsigned int>& children) const { std::list<Component*> compList; compList.push_back(_coarseComponents.getValue()[hexaId]); Component* comp = compList.front(); while(!comp->_children.empty()) { for(std::set<Component*>::iterator iter = comp->_children.begin(); iter != comp->_children.end(); ++iter) { compList.push_back(*iter); } compList.pop_front(); comp = compList.front(); } std::set<Component*> compSet; compSet.insert(compList.begin(), compList.end()); children.reserve(compSet.size()); for(unsigned int i=0; i<_fineComponents.getValue().size(); ++i) { if(compSet.find(_fineComponents.getValue()[i]) != compSet.end()) children.push_back(i); } return (int) children.size(); }
/// Generate discrete mass position values with variational sympletic implicit solver void generateDiscreteMassPositions (double h, double K, double m, double z0, double v0,double g, double finalTime, double rm,double rk) { int size = 0 ; // During t=finalTime if((finalTime/h) > 0) { size = int(finalTime/h); positionsArray.reserve(size); velocitiesArray.reserve(size); energiesArray.reserve(size); } // First velocity is v0 velocitiesArray.push_back(v0); // First acceleration energiesArray.push_back(m*v0); // First position is z0 positionsArray.push_back(double(z0)); // Compute totalEnergy totalEnergy = m*g*z0; // energy at initial time // Set constants double denominator = 4*m+h*h*K+4*h*(rm*m + rk*K);//4*h*(-rk*K+rm*m); double constant = -h*K; // Compute velocities, energies and positions for(int i=1;i< size+1; i++) { velocitiesArray.push_back(2*(-m*g*h+constant*(positionsArray[i-1]-z0)+2*energiesArray[i-1])/denominator); energiesArray.push_back(m*velocitiesArray[i]+h*(-K*(positionsArray[i-1]- z0+velocitiesArray[i]*h/2) -m*g)/2); positionsArray.push_back(positionsArray[i-1]+h*velocitiesArray[i]); } }