double DelaunayTriangle :: giveEdgeLength(int nodeA, int nodeB) { DofManager *dmanA = domain->giveDofManager( giveNode(nodeA) ); DofManager *dmanB = domain->giveDofManager( giveNode(nodeB) ); return dmanA->giveCoordinates()->distance( dmanB->giveCoordinates() ); }
void SloanGraph :: numberIsolatedNodes(int &NextNumber, int &labeledNodes) { int i, nnodes = domain->giveNumberOfDofManagers(); for ( i = 1; i <= nnodes; i++ ) { if ( giveNode(i)->giveDegree() == 0 ) { giveNode(i)->setNewNumber(++NextNumber); labeledNodes++; } } }
void CohesiveSurface3d :: drawDeformedGeometry(oofegGraphicContext &gc, TimeStep *tStep, UnknownType type) { GraphicObj *go1, *go2; if ( !gc.testElementGraphicActivity(this) ) { return; } double defScale = gc.getDefScale(); WCRec p [ 2 ]; EASValsSetLineWidth(OOFEG_DEFORMED_GEOMETRY_WIDTH); EASValsSetColor( gc.getDeformedElementColor() ); EASValsSetLayer(OOFEG_DEFORMED_GEOMETRY_LAYER); // get the displaced particle coordinates Particle *nodeA = ( Particle * ) giveNode(1); Particle *nodeB = ( Particle * ) giveNode(2); p [ 0 ].x = nodeA->giveUpdatedCoordinate(1, tStep, defScale); p [ 0 ].y = nodeA->giveUpdatedCoordinate(2, tStep, defScale); p [ 0 ].z = nodeA->giveUpdatedCoordinate(3, tStep, defScale); p [ 1 ].x = nodeB->giveUpdatedCoordinate(1, tStep, defScale); p [ 1 ].y = nodeB->giveUpdatedCoordinate(2, tStep, defScale); p [ 1 ].z = nodeB->giveUpdatedCoordinate(3, tStep, defScale); // plot the displaced particles EASValsSetMType(FILLED_CIRCLE_MARKER); EASValsSetColor( gc.getNodeColor() ); EASValsSetMSize(6); // plot the first particle go1 = CreateMarker3D(p); EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK | MTYPE_MASK | MSIZE_MASK, go1); EMAddGraphicsToModel(ESIModel(), go1); // take into account periodic conditions if ( giveNumberOfNodes() == 3 ) { Node *nodeC = ( Particle * ) giveNode(3); p [ 1 ].x += kxa + kxa * defScale * ( nodeC->giveDofWithID(D_u)->giveUnknown(VM_Total, tStep) ) + kyb * defScale * ( nodeC->giveDofWithID(R_u)->giveUnknown(VM_Total, tStep) ); p [ 1 ].y += kyb + kyb * defScale * ( nodeC->giveDofWithID(D_v)->giveUnknown(VM_Total, tStep) ) + kzc * defScale * ( nodeC->giveDofWithID(R_v)->giveUnknown(VM_Total, tStep) ); p [ 1 ].z += kzc + kzc * defScale * ( nodeC->giveDofWithID(D_w)->giveUnknown(VM_Total, tStep) ) + kxa * defScale * ( nodeC->giveDofWithID(R_w)->giveUnknown(VM_Total, tStep) ); EASValsSetMType(CIRCLE_MARKER); } // plot the second particle go2 = CreateMarker3D(p + 1); EGWithMaskChangeAttributes(COLOR_MASK | LAYER_MASK | MTYPE_MASK | MSIZE_MASK, go2); EMAddGraphicsToModel(ESIModel(), go2); }
void SloanGraph :: assignOldNumbers() { int i, nnodes = domain->giveNumberOfDofManagers(); for ( i = 1; i <= nnodes; i++ ) { giveNode(i)->assignOldNumber(); } }
void LineSurfaceTension :: computeLoadVector(FloatArray &answer, ValueModeType mode, TimeStep *tStep) { domainType dt = this->giveDomain()->giveDomainType(); Node *node1, *node2; FloatArray v1, v2, v; double x1, x2, length, t, gamma_s; gamma_s = this->giveMaterial()->give('g',NULL); node1 = giveNode(1); node2 = giveNode(2); v.beDifferenceOf(*node2->giveCoordinates(), *node1->giveCoordinates()); length = v.computeNorm(); v.times(1.0/length); x1 = node1->giveCoordinate(1); x2 = node1->giveCoordinate(2); answer.resize(4); answer.zero(); if (dt == _3dAxisymmMode) { OOFEM_CLASS_ERROR("Not tested"); t = M_PI*(x1+x2); answer.at(1) = v.at(1)*t - length; answer.at(2) = v.at(2)*t; answer.at(3) = -v.at(1)*t - length; answer.at(4) = -v.at(2)*t; } else { //t = this->giveDomain()->giveCrossSection(1)->give(CS_Thickness); t = 1.0; // In this case simple linear case, the boundary term would cancel out the edge term, // so it can be simplified to check when the boundary is not there. answer.at(1) = v.at(1)*t; answer.at(2) = v.at(2)*t; answer.at(3) = -v.at(1)*t; answer.at(4) = -v.at(2)*t; } answer.times(gamma_s); }
void SloanGraph :: initStatusAndPriority() { int i; this->findPeripheralNodes(); #ifndef MDC this->evaluateNodeDistances(); int nnodes = domain->giveNumberOfDofManagers(); for ( i = 1; i <= nnodes; i++ ) { int Distance = giveNode(i)->giveDistance(); int Degree = giveNode(i)->giveDegree(); int Priority = WeightDistance * Distance - WeightDegree * ( Degree + 1 ); giveNode(i)->setPriority(Priority); giveNode(i)->setStatus(SloanGraphNode :: Inactive); } #else int NumLevels; int j; IntArray *Level; int End = endNode; int Distance, Degree, Priority; SloanLevelStructure BackSpine(this, End); NumLevels = BackSpine.giveDepth(); for ( i = 1; i <= NumLevels; i++ ) { Level = BackSpine.giveLevel(i); for ( j = 1; j <= Level->giveSize(); j++ ) { Distance = i - 1; this->giveNode( Level->at(j) )->setDistance(Distance); Degree = this->giveNode( Level->at(j) )->giveDegree(); Priority = WeightDistance * Distance - WeightDegree * ( Degree + 1 ); this->giveNode( Level->at(j) )->setPriority(Priority); this->giveNode( Level->at(j) )->setStatus(SloanGraphNode :: Inactive); } } #endif }
void Line2SurfaceTension :: computeLoadVector(FloatArray &answer, ValueModeType mode, TimeStep *tStep) { ///@todo Support axisymm. //domainType dt = this->giveDomain()->giveDomainType(); IntegrationRule *iRule = this->integrationRulesArray [ 0 ]; double t = 1, gamma_s; ///@todo Should i use this? Not used in FM module (but perhaps it should?) / Mikael. //t = this->giveDomain()->giveCrossSection(1)->give(CS_Thickness); gamma_s = this->giveMaterial()->give('g', NULL); FloatMatrix xy(2, 3); Node *node; for ( int i = 1; i <= 3; i++ ) { node = giveNode(i); xy.at(1, i) = node->giveCoordinate(1); xy.at(2, i) = node->giveCoordinate(2); } FloatArray A; FloatArray dNdxi(3); FloatArray es(2); // tangent vector to curve FloatMatrix BJ(2, 6); BJ.zero(); answer.resize(6); answer.zero(); for ( int k = 0; k < iRule->getNumberOfIntegrationPoints(); k++ ) { GaussPoint *gp = iRule->getIntegrationPoint(k); //interpolation.evaldNdx(dN, domain, dofManArray, * gp->giveCoordinates(), 0.0); double xi = gp->giveCoordinate(1); // Some simplifications can be performed, since the mapping J is a scalar. dNdxi.at(1) = -0.5 + xi; dNdxi.at(2) = 0.5 + xi; dNdxi.at(3) = -2.0 * xi; es.beProductOf(xy, dNdxi); double J = es.computeNorm(); es.times(1 / J); //es.normalize(); // dNds = dNdxi/J // B.at(1,1) = dNds.at(1); and so on. BJ.at(1, 1) = BJ.at(2, 2) = dNdxi.at(1); BJ.at(1, 3) = BJ.at(2, 4) = dNdxi.at(2); BJ.at(1, 5) = BJ.at(2, 6) = dNdxi.at(3); A.beTProductOf(BJ, es); answer.add( - gamma_s * t * gp->giveWeight(), A); // Note! Negative sign! } }
void DelaunayTriangle :: computeCircumcircle() { double x1, x2, x3; double y1, y2, y3; double a, bx, by, c; DofManager *dmanA, *dmanB, *dmanC; dmanA = domain->giveDofManager( giveNode(1) ); x1 = dmanA->giveCoordinate(1); y1 = dmanA->giveCoordinate(2); dmanB = domain->giveDofManager( giveNode(2) ); x2 = dmanB->giveCoordinate(1); y2 = dmanB->giveCoordinate(2); dmanC = domain->giveDofManager( giveNode(3) ); x3 = dmanC->giveCoordinate(1); y3 = dmanC->giveCoordinate(2); a = x1 * y2 + y1 * x3 + x2 * y3 - 1.0 * ( x1 * y3 + y1 * x2 + y2 * x3 ); bx = -1.0 * ( ( ( x1 * x1 + y1 * y1 ) * y2 + y1 * ( x3 * x3 + y3 * y3 ) + ( x2 * x2 + y2 * y2 ) * y3 ) - 1.0 * ( ( x1 * x1 + y1 * y1 ) * y3 + y1 * ( x2 * x2 + y2 * y2 ) + y2 * ( x3 * x3 + y3 * y3 ) ) ); by = ( ( ( x1 * x1 + y1 * y1 ) * x2 + x1 * ( x3 * x3 + y3 * y3 ) + ( x2 * x2 + y2 * y2 ) * x3 ) - 1.0 * ( ( x1 * x1 + y1 * y1 ) * x3 + x1 * ( x2 * x2 + y2 * y2 ) + x2 * ( x3 * x3 + y3 * y3 ) ) ); c = ( ( ( x1 * x1 + y1 * y1 ) * x2 * y3 + x1 * y2 * ( x3 * x3 + y3 * y3 ) + y1 * ( x2 * x2 + y2 * y2 ) * x3 ) - 1.0 * ( ( x1 * x1 + y1 * y1 ) * y2 * x3 + x1 * ( x2 * x2 + y2 * y2 ) * y3 + y1 * x2 * ( x3 * x3 + y3 * y3 ) ) ); double xCenterCoordinate = ( -1.0 * bx / ( 2 * a ) ); double yCenterCoordinate = ( -1.0 * by / ( 2 * a ) ); double absA = a < 0 ? -1.0 * a : a; double radius = ( ( sqrt(bx * bx + by * by + 4.0 * a * c) ) / ( 2.0 * absA ) ); setCircumCircle(xCenterCoordinate, yCenterCoordinate, radius); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), logic(this), connectDialog(new ZeroconfConnectDialog(this)), ipConnectDialog(new IPConnectDialog(this)) { ui->setupUi(this); ui->centralwidget->setClientLogic(&logic); /* connect(connectDialog, SIGNAL(connectedTo(QHostAddress,quint16)), this, SLOT(newServerConnection(QHostAddress,quint16))); */ connect(ipConnectDialog, SIGNAL(setLocalAddress(QHostAddress)), &logic, SLOT(setLocalAddress(QHostAddress))); connect(ipConnectDialog, SIGNAL(connectedTo(QHostAddress,quint16)), this, SLOT(newServerConnection(QHostAddress,quint16))); connect(ui->centralwidget, SIGNAL(take(QString)), this, SLOT(takeNode(QString))); connect(ui->centralwidget, SIGNAL(give(QString)), this, SLOT(giveNode(QString))); connect(&logic, SIGNAL(serverPoolChanged()), ui->centralwidget, SLOT(updateServerPool())); connect(&logic, SIGNAL(localPoolChanged()), ui->centralwidget, SLOT(updateLocalPool())); connect(&logic, SIGNAL(sendLog(QString)), ui->centralwidget, SLOT(addLog(QString))); }
void CohesiveSurface3d :: drawScalar(oofegGraphicContext &gc, TimeStep *tStep) { if ( !gc.testElementGraphicActivity(this) ) { return; } FloatArray val; GaussPoint *gp = integrationRulesArray [ 0 ]->getIntegrationPoint(0); if ( !giveIPValue(val, gp, gc.giveIntVarType(), tStep) ) { return; } int indx = gc.giveIntVarIndx(); double s [ 8 ]; for ( int i = 0; i < 8; i++ ) { s [ i ] = val.at(indx); } gc.updateFringeTableMinMax(s, 1); WCRec p [ 8 ]; Particle *nodeA = ( Particle * ) giveNode(1); Particle *nodeB = ( Particle * ) giveNode(2); if ( gc.getInternalVarsDefGeoFlag() ) { // use deformed geometry double defScale = gc.getDefScale(); p [ 0 ].x = nodeA->giveUpdatedCoordinate(1, tStep, defScale); p [ 0 ].y = nodeA->giveUpdatedCoordinate(2, tStep, defScale); p [ 0 ].z = nodeA->giveUpdatedCoordinate(3, tStep, defScale); p [ 2 ].x = nodeB->giveUpdatedCoordinate(1, tStep, defScale); p [ 2 ].y = nodeB->giveUpdatedCoordinate(2, tStep, defScale); p [ 2 ].z = nodeB->giveUpdatedCoordinate(3, tStep, defScale); // handle special elements crossing the boundary of the periodic cell if ( giveNumberOfNodes() == 3 ) { Node *nodeC = ( Particle * ) giveNode(3); p [ 2 ].x += kxa + kxa * defScale * ( nodeC->giveDofWithID(D_u)->giveUnknown(VM_Total, tStep) ) + kyb * defScale * ( nodeC->giveDofWithID(R_u)->giveUnknown(VM_Total, tStep) ); p [ 2 ].y += kyb + kyb * defScale * ( nodeC->giveDofWithID(D_v)->giveUnknown(VM_Total, tStep) ) + kzc * defScale * ( nodeC->giveDofWithID(R_v)->giveUnknown(VM_Total, tStep) ); p [ 2 ].z += kzc + kzc * defScale * ( nodeC->giveDofWithID(D_w)->giveUnknown(VM_Total, tStep) ) + kxa * defScale * ( nodeC->giveDofWithID(R_w)->giveUnknown(VM_Total, tStep) ); } } else { // use initial geometry p [ 0 ].x = nodeA->giveCoordinate(1); p [ 0 ].y = nodeA->giveCoordinate(2); p [ 0 ].z = nodeA->giveCoordinate(3); p [ 2 ].x = nodeB->giveCoordinate(1); p [ 2 ].y = nodeB->giveCoordinate(2); p [ 2 ].z = nodeB->giveCoordinate(3); // handle special elements crossing the boundary of the periodic cell if ( giveNumberOfNodes() == 3 ) { p [ 2 ].x += kxa; p [ 2 ].y += kyb; p [ 2 ].z += kzc; } } double r1 = nodeA->giveRadius(); double r2 = nodeB->giveRadius(); double d = 0.1 * ( r1 + r2 ); p [ 1 ].x = 0.5 * ( p [ 0 ].x + p [ 2 ].x - d * lcs.at(2, 1) - d * lcs.at(3, 1) ); p [ 1 ].y = 0.5 * ( p [ 0 ].y + p [ 2 ].y - d * lcs.at(2, 2) - d * lcs.at(3, 2) ); p [ 1 ].z = 0.5 * ( p [ 0 ].z + p [ 2 ].z - d * lcs.at(2, 3) - d * lcs.at(3, 3) ); p [ 3 ].x = p [ 1 ].x + d *lcs.at(2, 1); p [ 3 ].y = p [ 1 ].y + d *lcs.at(2, 2); p [ 3 ].z = p [ 1 ].z + d *lcs.at(2, 3); for ( int i = 5; i < 8; i += 2 ) { p [ i ].x = p [ i - 4 ].x + d *lcs.at(3, 1); p [ i ].y = p [ i - 4 ].y + d *lcs.at(3, 2); p [ i ].z = p [ i - 4 ].z + d *lcs.at(3, 3); } p [ 4 ] = p [ 0 ]; p [ 6 ] = p [ 2 ]; GraphicObj *go = CreateHexahedronWD(p, s); EASValsSetLayer(OOFEG_VARPLOT_PATTERN_LAYER); EASValsSetLineWidth(2 * OOFEG_DEFORMED_GEOMETRY_WIDTH); EASValsSetFillStyle(FILL_SOLID); //EGWithMaskChangeAttributes(WIDTH_MASK | COLOR_MASK | LAYER_MASK, go); EGWithMaskChangeAttributes(WIDTH_MASK | FILL_MASK | LAYER_MASK, go); EMAddGraphicsToModel(ESIModel(), go); }
void LineSurfaceTension :: computeTangent(FloatMatrix &answer, TimeStep *tStep) { #if 1 ///@todo Not sure if it's a good idea to use this tangent. answer.resize(4,4); answer.zero(); #else domainType dt = this->giveDomain()->giveDomainType(); int ndofs = this->computeNumberOfDofs(EID_MomentumBalance); Node *node1, *node2; double x1, x2, y1, y2, dx, dy, vx, vy, length, width, gamma_s; gamma_s = this->giveMaterial()->give('g',NULL); node1 = giveNode(1); node2 = giveNode(2); x1 = node1->giveCoordinate(1); x2 = node2->giveCoordinate(1); y1 = node1->giveCoordinate(2); y2 = node2->giveCoordinate(2); dx = x2-x1; dy = y2-y1; length = sqrt(dx*dx + dy*dy); vx = dx/length; vy = dy/length; FloatArray Ah(4); Ah.at(1) = -vx; Ah.at(2) = -vy; Ah.at(3) = vx; Ah.at(4) = vy; FloatMatrix NpTNp(4,4); NpTNp.zero(); NpTNp.at(1,1) = 1; NpTNp.at(2,2) = 1; NpTNp.at(3,3) = 1; NpTNp.at(4,4) = 1; NpTNp.at(1,3) = -1; NpTNp.at(2,4) = -1; NpTNp.at(3,1) = -1; NpTNp.at(4,2) = -1; answer.resize(ndofs,ndofs); answer.zero(); if (dt == _3dAxisymmMode) { OOFEM_WARNING("Not tested"); FloatArray Bh(4); Bh.zero(); Bh.at(1) = 1; Bh.at(3) = 1; // It was simpler to write this in index notation. // Also using 0-based, to reduce typing double rJinv = (x1+x2)/length; answer.zero(); for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) { answer(i,j) = M_PI*(Ah(i)*Bh(j) + Bh(i)*Ah(j)+ rJinv*(NpTNp(i,j) - Ah(i)*Ah(j))); } } else { width = 1; answer.beDyadicProductOf(Ah,Ah); answer.add(NpTNp); answer.times(width/length); } answer.times(gamma_s); #endif }
void Line2SurfaceTension :: computeTangent(FloatMatrix &answer, TimeStep *tStep) { #if 1 answer.resize(6, 6); answer.zero(); #else ///@todo Support axisymm. domainType dt = this->giveDomain()->giveDomainType(); if (dt == _3dAxisymmMode) { OOFEM_ERROR("Line2SurfaceTension :: computeTangent - Axisymm not implemented"); } IntegrationRule *iRule = this->integrationRulesArray [ 0 ]; double t = 1, gamma_s; ///@todo Should i use this? Not that meaningful for flow problems. //t = this->giveDomain()->giveCrossSection(1)->give(CS_Thickness); gamma_s = this->giveMaterial()->give('g', NULL); FloatMatrix xy(2,3); Node *node; for (int i = 1; i <= 3; i++) { node = giveNode(i); xy.at(1,i) = node->giveCoordinate(1); xy.at(2,i) = node->giveCoordinate(2); } FloatArray A; FloatArray dNdxi(3); FloatArray es(2); // tangent vector to curve FloatMatrix BJ(2,6); BJ.zero(); FloatMatrix temp1,temp2; answer.resize(6,6); answer.zero(); for (int k = 0; k < iRule->getNumberOfIntegrationPoints(); k++ ) { GaussPoint *gp = iRule->getIntegrationPoint(k); double xi = gp->giveCoordinate(1); dNdxi.at(1) = -0.5+xi; dNdxi.at(2) = 0.5+xi; dNdxi.at(3) = -2.0*xi; es.beProductOf(xy,dNdxi); double J = es.computeNorm(); es.times(1/J); //es.normalize(); BJ.at(1,1) = BJ.at(2,2) = dNdxi.at(1); BJ.at(1,3) = BJ.at(2,4) = dNdxi.at(2); BJ.at(1,5) = BJ.at(2,6) = dNdxi.at(3); A.beTProductOf(BJ,es); temp1.beTProductOf(BJ,BJ); temp2.beDyadicProductOf(A,A); temp1.subtract(temp2); temp1.times(t*gp->giveWeight()/J*(tStep->giveTimeIncrement())); answer.add(temp1); } answer.times(gamma_s); #endif }
void SloanGraph :: assignNewNumbers() { int Start, inext, NextNumber = 0; int labeledNodes = 0; int i, nnodes = domain->giveNumberOfDofManagers(); for ( i = 1; i <= nnodes; i++ ) { giveNode(i)->setNewNumber(0); } #ifdef MDC this->numberIsolatedNodes(NextNumber, labeledNodes); #endif this->initStatusAndPriority(); SloanGraphNode *nextNode; //std::list<int>::iterator next; Start = this->startNode; this->queue.clear(); this->queue.push_back(Start); this->giveNode(Start)->setStatus(SloanGraphNode :: Preactive); #ifdef MDC for ( ; ; ) { #endif while ( !this->queue.empty() ) { // finds top priority, returns the corresponding node and deletes the entry inext = findTopPriorityInQueue(); // this->queue.erase(next); - done by findTopPriority nextNode = this->giveNode(inext); if ( nextNode->giveStatus() == SloanGraphNode :: Preactive ) { this->insertNeigborsOf(inext); } nextNode->setNewNumber(++NextNumber); nextNode->setStatus(SloanGraphNode :: Postactive); modifyPriorityAround(inext); labeledNodes++; } #ifdef MDC if ( labeledNodes == domain->giveNumberOfDofManagers() ) { break; } // proceed next subdomain this->initStatusAndPriority(); Start = this->startNode; this->queue.clear(); this->queue.push_back(Start); this->giveNode(Start)->setStatus(SloanGraphNode :: Preactive); } #else if ( labeledNodes != domain->giveNumberOfDofManagers() ) { OOFEM_ERROR2("SloanGraph :: assignNewNumbers: Internal error:\n%s", "Isolated nodes or separated sub-domains exist"); } #endif }