int slirp_get_system_dns_servers(void) { char buff[512]; char buff2[257]; FILE *f; if (dns_addr_count > 0) return dns_addr_count; #ifdef CONFIG_DARWIN /* on Darwin /etc/resolv.conf is a symlink to /private/var/run/resolv.conf * in some siutations, the symlink can be destroyed and the system will not * re-create it. Darwin-aware applications will continue to run, but "legacy" * Unix ones will not. */ f = fopen("/private/var/run/resolv.conf", "r"); if (!f) f = fopen("/etc/resolv.conf", "r"); /* desperate attempt to sanity */ #else f = fopen("/etc/resolv.conf", "r"); #endif if (!f) return -1; DN("emulator: IP address of your DNS(s): "); while (fgets(buff, 512, f) != NULL) { if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) { uint32_t tmp_ip; if (inet_strtoip(buff2, &tmp_ip) < 0) continue; if (tmp_ip == loopback_addr_ip) tmp_ip = our_addr_ip; if (dns_addr_count < DNS_ADDR_MAX) { dns_addr[dns_addr_count++] = tmp_ip; if (dns_addr_count > 1) DN(", "); DN("%s", inet_iptostr(tmp_ip)); } else { DN("(more)"); break; } } } DN("\n"); fclose(f); if (!dns_addr_count) return -1; return dns_addr_count; }
double Black::impliedVol( double strike, // option strike double forwardPrice, // underlying asset's forward value double marketPrice, // market price of option double rate, // risk free rate of interest double T ) const // time to maturity (year fraction) { int iterations = 100; double vol = 0.5; double sqrtT = sqrt(T); double logTerm = log(forwardPrice / strike); while (--iterations) { double p1 = value(strike, forwardPrice, vol, rate, T, true) - marketPrice; if (nearZero(p1)) break; // vega(vol) double d1 = ( logTerm + (((vol * vol) / 2.0)) * T ) / (vol * sqrtT); double p2 = forwardPrice * exp( -rate * T ) * sqrtT * DN(d1); vol = vol - (p1 / p2); } return vol; }
VectorF Assembler::getCurlNorm(double* vector_field, int num_vector_field) { size_t num_node = m_mesh->getNbrNodes(); size_t num_elem = m_mesh->getNbrElements(); size_t dim = m_mesh->getDim(); assert(num_vector_field == dim*num_node); VectorF curl_norm(num_elem); for (size_t i=0; i<num_elem; i++) { VectorI elem = m_mesh->getElement(i); const Eigen::MatrixXd& DN = m_DN[i]; Eigen::Vector3d curl(0, 0, 0); for (size_t j=0; j<elem.size(); j++) { Eigen::Vector3d v(0, 0, 0); Eigen::Vector3d grad(0, 0, 0); for (size_t k=0; k<dim; k++) { v[k] = vector_field[elem[j]*dim+k]; grad[k] = DN(j, k); } curl = curl + grad.cross(v); } curl_norm[i] = curl.norm(); } return curl_norm; }
int slirp_get_system_dns_servers(void) { char buff[512]; char buff2[257]; FILE *f; if (dns_addr_count > 0) return dns_addr_count; #ifdef CONFIG_DARWIN f = fopen("/private/var/run/resolv.conf", "r"); if (!f) f = fopen("/etc/resolv.conf", "r"); #else f = fopen("/etc/resolv.conf", "r"); #endif if (!f) return -1; DN("emulator: IP address of your DNS(s): "); while (fgets(buff, 512, f) != NULL) { if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) { uint32_t tmp_ip; if (inet_strtoip(buff2, &tmp_ip) < 0) continue; if (tmp_ip == loopback_addr_ip) tmp_ip = our_addr_ip; if (dns_addr_count < DNS_ADDR_MAX) { dns_addr[dns_addr_count++] = tmp_ip; if (dns_addr_count > 1) DN(", "); DN("%s", inet_iptostr(tmp_ip)); } else { DN("(more)"); break; } } } DN("\n"); fclose(f); if (!dns_addr_count) return -1; return dns_addr_count; }
double Black::vega( double strike, // option strike double forwardPrice, // underlying asset's forward value double vol, // volatility double rate, // risk free rate of interest double T ) const // time to maturity (year fraction) { double d1 = ( log(forwardPrice / strike) + (((vol * vol) / 2.0)) * T ) / (vol * sqrt(T)); return forwardPrice * exp( -rate * T ) * sqrt(T) * DN(d1); }
void studentPasswords::showClass(string schoolClass) { currentClass = schoolClass; table->clear(); table->elementAt(0,0)->addWidget(new Wt::WText("Naam")); table->elementAt(0,1)->addWidget(new Wt::WText("HoofdAccount")); table->elementAt(0,2)->addWidget(new Wt::WText("CoAccount 1")); table->elementAt(0,3)->addWidget(new Wt::WText("CoAccount 2")); table->elementAt(1,0)->addWidget(new Wt::WText("Select all")); Wt::WCheckBox * checkMain = new Wt::WCheckBox(); table->elementAt(1,1)->addWidget(checkMain); checkMain->clicked().connect(std::bind([=] () { for(int i = 2; i < table->rowCount(); i++) { ((Wt::WCheckBox*)(table->elementAt(i, 1)->widget(0)))->setChecked(checkMain->isChecked()); } })); Wt::WCheckBox * checkCo1 = new Wt::WCheckBox(); table->elementAt(1,2)->addWidget(checkCo1); checkCo1->clicked().connect(std::bind([=] () { for(int i = 2; i < table->rowCount(); i++) { ((Wt::WCheckBox*)(table->elementAt(i, 2)->widget(0)))->setChecked(checkCo1->isChecked()); } })); Wt::WCheckBox * checkCo2 = new Wt::WCheckBox(); table->elementAt(1,3)->addWidget(checkCo2); checkCo2->clicked().connect(std::bind([=] () { for(int i = 2; i < table->rowCount(); i++) { ((Wt::WCheckBox*)(table->elementAt(i, 3)->widget(0)))->setChecked(checkCo2->isChecked()); } })); table->setHeaderCount(2, Wt::Orientation::Horizontal); y::ldap::schoolClass & sc = server->getClass(CN(schoolClass)); int row = 0; for(auto it = sc.students().begin(); it != sc.students().end(); ++it) { y::ldap::account & student = server->getAccount(DN(*it)); table->elementAt(2+row,0)->addWidget(new Wt::WText(student.fullName().get().wt())); table->elementAt(2+row,1)->addWidget(new Wt::WCheckBox()); table->elementAt(2+row,2)->addWidget(new Wt::WCheckBox()); table->elementAt(2+row,3)->addWidget(new Wt::WCheckBox()); row++; } for(int i = 0; i < table->rowCount(); i++) { for(int j = 0; j < table->columnCount(); j++) { table->elementAt(i, j)->setPadding(5); table->elementAt(i, j)->setVerticalAlignment(Wt::AlignMiddle); } } }
double Black::theta( double strike, // option strike double forwardPrice, // underlying asset's forward value double vol, // volatility double rate, // risk free rate of interest double T, // time to maturity (year fraction) bool call ) const // annualised dividend yield of asset (continuous compounded) { double tmp = vol * sqrt(T); double d1 = ( log(forwardPrice / strike) + (((vol * vol) / 2.0)) * T ) / tmp; double d2 = d1 - tmp; double term = (forwardPrice * exp(-rate * T) * DN(d1) * vol) / (2.0 * sqrt(T)); if (call) return -term + (rate * forwardPrice * exp( -rate * T ) * N(d1)) - (rate * strike * exp(-rate * T) * N(d2)); else return -term - (rate * forwardPrice * exp( -rate * T ) * N(-d1)) + (rate * strike * exp(-rate * T) * N(-d2)); }
VectorF Assembler::getDivergence(double* vector_field, int num_vector_field) { size_t num_node = m_mesh->getNbrNodes(); size_t num_elem = m_mesh->getNbrElements(); size_t dim = m_mesh->getDim(); assert(num_vector_field == dim*num_node); VectorF div(num_elem); for (size_t i=0; i<num_elem; i++) { div[i] = 0; VectorI elem = m_mesh->getElement(i); const Eigen::MatrixXd& DN = m_DN[i]; for (size_t j=0; j<elem.size(); j++) { for (size_t k=0; k<dim; k++) { div[i] += DN(j,k) * vector_field[elem[j]*dim+k]; } } } return div; }
y::ldap::account::account(y::ldap::server * server) : server(server), // var name in ldap type and init is int? _uidNumber (TYPE_UIDNUMBER , UID_NUMBER (0 )), _uid (TYPE_UID , UID ("")), _dn ("DN" , DN ("")), _cn (TYPE_CN , CN ("")), _sn ("sn" , SN ("")), _fullName ("displayName" , FULL_NAME ("")), _homeDir ("homeDirectory" , HOMEDIR ("")), _wisaID ("wisaID" , WISA_ID (0 )), _wisaName (TYPE_WISANAME , WISA_NAME ("")), _mail ("mail" , MAIL ("")), _mailAlias ("mailAlias" , MAIL_ALIAS ("")), _birthDay ("birthday" , DATE(DAY(1), MONTH(1), YEAR(1))), _password ("gMailPassword" , PASSWORD ("")), _role ("schoolRole" , ROLE(ROLE::NONE)), _groupID ("gidNumber" , GID_NUMBER (0 )), _schoolClass ("class" , SCHOOLCLASS("")), _classChange ("classChangeDate" , DATE(DAY(1), MONTH(1), YEAR(1))), _birthPlace ("placeOfBirth" , BIRTHPLACE ("")), _gender ("gender" , GENDER(GENDER::MALE) ), _adminGroup ("adminGroupID" , ADMINGROUP (0 )), _registerID ("nationalRegisterID", REGISTER_ID("")), _nationality ("nationality" , NATION ("")), _stemID ("stemID" , STEM_ID (0 )), _schoolID ("schoolID" , SCHOOL_ID (0 )), _houseNumber ("houseNumber" , HOUSENUMBER(0 )), _houseNumberAdd("houseNumberAdd" , HOUSENUMBER_ADD("") ), _city ("location" , CITY ("")), _postalCode ("postalCode" , POSTAL_CODE("")), _street ("street" , STREET ("")), _country ("co" , COUNTRY ("")), _new(true), _hasKrbName(false), _hasSchoolPersonClass(false), _importStatus(WI_NOT_ACCOUNTED), _flaggedForRemoval(false) {}
void y::ldap::account::clear() { _new = true; _hasKrbName = false; _hasSchoolPersonClass = false; _uidNumber .reset(UID_NUMBER (0 )); _uid .reset(UID ("")); _dn .reset(DN ("")); _cn .reset(CN ("")); _sn .reset(SN ("")); _fullName .reset(FULL_NAME ("")); _homeDir .reset(HOMEDIR ("")); _wisaID .reset(WISA_ID (0 )); _wisaName .reset(WISA_NAME ("")); _mail .reset(MAIL ("")); _mailAlias .reset(MAIL_ALIAS ("")); _birthDay .reset(DATE(DAY(1), MONTH(1), YEAR(1))); _password .reset(PASSWORD ("")); _role .reset(ROLE(ROLE::NONE)); _groupID .reset(GID_NUMBER (0 )); _schoolClass .reset(SCHOOLCLASS("")); _birthPlace .reset(BIRTHPLACE ("")); _gender .reset(GENDER(GENDER::MALE)); _adminGroup .reset(ADMINGROUP (0 )); _registerID .reset(REGISTER_ID("")); _nationality .reset(NATION ("")); _stemID .reset(STEM_ID (0 )); _schoolID .reset(SCHOOL_ID (0 )); _street .reset(STREET ("")); _houseNumber .reset(HOUSENUMBER(0 )); _houseNumberAdd.reset(HOUSENUMBER_ADD("")); _city .reset(CITY ("")); _postalCode .reset(POSTAL_CODE("")); _country .reset(COUNTRY ("")); _ssPassword.clear(); _flaggedForRemoval = false; }
bool LookupOper(const std::string& opername, const std::string& opassword) { if (conn == NULL) if (!Connect()) return false; int res; char* authpass = strdup(password.c_str()); // bind anonymously if no bind DN and authentication are given in the config struct berval cred; cred.bv_val = authpass; cred.bv_len = password.length(); if ((res = ldap_sasl_bind_s(conn, username.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL)) != LDAP_SUCCESS) { if (res == LDAP_SERVER_DOWN) { // Attempt to reconnect if the connection dropped ServerInstance->SNO->WriteToSnoMask('a', "LDAP server has gone away - reconnecting..."); Connect(); res = ldap_sasl_bind_s(conn, username.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); } if (res != LDAP_SUCCESS) { free(authpass); ldap_unbind_ext(conn, NULL, NULL); conn = NULL; return false; } } free(authpass); LDAPMessage *msg, *entry; std::string what = attribute + "=" + opername; if ((res = ldap_search_ext_s(conn, base.c_str(), searchscope, what.c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg)) != LDAP_SUCCESS) { return false; } if (ldap_count_entries(conn, msg) > 1) { ldap_msgfree(msg); return false; } if ((entry = ldap_first_entry(conn, msg)) == NULL) { ldap_msgfree(msg); return false; } authpass = strdup(opassword.c_str()); cred.bv_val = authpass; cred.bv_len = opassword.length(); RAIILDAPString DN(ldap_get_dn(conn, entry)); if ((res = ldap_sasl_bind_s(conn, DN, LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL)) == LDAP_SUCCESS) { free(authpass); ldap_msgfree(msg); return true; } else { free(authpass); ldap_msgfree(msg); return false; } }
void studentPasswords::changePasswords() { buttons->hide(); table->hide(); pfile.clear(string("wachtwoorden ") + currentClass); y::ldap::schoolClass & sc = server->getClass(CN(currentClass)); progress->setRange(0, sc.students().size()); progress->show(); bool csv = false; if(((Wt::WCheckBox*)(table->elementAt(1,1)->widget(0)))->isChecked()) csv = true; if(((Wt::WCheckBox*)(table->elementAt(1,2)->widget(0)))->isChecked()) csv = true; if(((Wt::WCheckBox*)(table->elementAt(1,3)->widget(0)))->isChecked()) csv = true; int row = 0; for(auto it = sc.students().begin(); it != sc.students().end(); ++it) { y::ldap::account & a = server->getAccount(DN(*it)); // check main account if(((Wt::WCheckBox*)(table->elementAt(row+2, 1)->widget(0)))->isChecked()) { pfile.addLine(a.fullName().get()); { if(!csv) { string s("Klas: "); s += a.schoolClass().get(); pfile.addLine(s); } else { pfile.addCsv(a.schoolClass().get()); } } { if(!csv) { string s("Login: "******"Nieuw wachtwoord: "); s += a.getPasswordText(); pfile.addLine(s); string s2("Eenmalig Smartschool Wachtwoord: "); s2 += sspassword; pfile.addLine(s2); } else { pfile.addCsv(a.getPasswordText()); pfile.addCsv(sspassword); } } if(!csv) { pfile.addLine(" "); pfile.addLine("Laat je wachtwoord niet rondslingeren! Je bent verantwoordelijk voor je account. Indien je dit wachtwoord niet kan onthouden, pas dan je wachtwoord zelf aan via http://apps.sanctamaria-aarschot.be"); pfile.addLine(" "); } } // check co-account 1 if(((Wt::WCheckBox*)(table->elementAt(row+2, 2)->widget(0)))->isChecked()) { { if(!csv) { string s("Wachtwoord voor "); s += a.fullName().get(); pfile.addLine(s); } else { pfile.addLine(a.fullName().get()); pfile.addCsv("1ste co-account"); } } if (!csv) { string s(a.street().get()); s += " "; s += string(a.houseNumber().get()); s += " "; s += a.houseNumberAdd().get(); pfile.addLine(s); } if (!csv) { string s(a.postalCode().get()); s += " "; s += string(a.city().get()); pfile.addLine(s); } { if(!csv) { string s("Klas: "); s += a.schoolClass().get(); pfile.addLine(s); } else { pfile.addCsv(a.schoolClass().get()); } } { if(!csv) { string s("Login: "******"Wachtwoord 1ste Co-account: "); s += password; pfile.addLine(s); } else { pfile.addCsv(password); } } if(!csv) { pfile.addLine(" "); pfile.addLine("Met dit wachtwoord kan je als ouder inloggen op http://sanctamaria-aarschot.smartschool.be"); pfile.addLine(" "); } } // check co-account 2 if(((Wt::WCheckBox*)(table->elementAt(row+2, 3)->widget(0)))->isChecked()) { { if(!csv) { string s("Wachtwoord voor "); s += a.fullName().get(); pfile.addLine(s); } else { pfile.addLine(a.fullName().get()); pfile.addCsv("2de co-account"); } } if(!csv) { string s(a.street().get()); s += " "; s += string(a.houseNumber().get()); s += " "; s += a.houseNumberAdd().get(); pfile.addLine(s); } if(!csv) { string s(a.postalCode().get()); s += " "; s += string(a.city().get()); pfile.addLine(s); } { if(!csv) { string s("Klas: "); s += a.schoolClass().get(); pfile.addLine(s); } else { pfile.addCsv(a.schoolClass().get()); } } { if(!csv) { string s("Login: "******"Wachtwoord 2de Co-account: "); s += password; pfile.addLine(s); } else { pfile.addCsv(password); } } if(!csv) { pfile.addLine(" "); pfile.addLine("Met dit wachtwoord kan je als ouder inloggen op http://sanctamaria-aarschot.smartschool.be"); pfile.addLine(" "); } } progress->setValue(row); row++; } server->commitChanges(); progress->hide(); anchor->show(); }
void DBGXRender(int *address,int showDisplay) { int n = 0; char buffer[32],buffer2[4]; CPUSTATUS *s = CPUGetStatus(); GFXSetCharacterSize(32,23); DBGVerticalLabel(19,0,labels,DBGC_ADDRESS,-1); // Draw the labels for the register GFXDefineCharacter(127,0x3E,0x7F,0x7F,0x7F,0x3E); GFXDefineCharacter(126,0x3E,0x4F,0x4F,0x4F,0x3E); GFXDefineCharacter(125,0x3E,0x79,0x79,0x79,0x3E); #define DN(v,w) GFXNumber(GRID(22,n++),v,16,w,GRIDSIZE,DBGC_DATA,-1) // Helper macro //s->a = HWIReadKeyboard(); n = 0; DN(s->a,2);DN(s->e,2);DN(s->s,2); // Dump Registers etc. DN(s->p0,4);DN(s->p1,4);DN(s->p2,4);DN(s->p3,4); DN((s->s >> 7) & 1,1); _DBGBinary(22,n++,HWIGetLEDDisplay(),127,0xF00,127,0x400); _DBGBinary(22,n++,HWIGetToggleSwitches(),125,0x0F0,126,0x00F); DN(address[3],4);DN(s->cycles,4); int a = address[1]; // Dump Memory. for (int row = 13;row < 22;row++) { GFXNumber(GRID(2,row),a,16,4,GRIDSIZE,DBGC_ADDRESS,-1); GFXCharacter(GRID(6,row),':',GRIDSIZE,DBGC_HIGHLIGHT,-1); for (int col = 0;col < 8;col++) { GFXNumber(GRID(7+col*3,row),CPUReadMemory(a),16,2,GRIDSIZE,DBGC_DATA,-1); a = (a + 1) & 0xFFFF; } } int p = address[0]; // Dump program code. int opc,opr; for (int row = 0;row < 12;row++) { int isPC = (p == ((s->p0+1) & 0xFFFF)); // Tests. int isBrk = (p == address[3]); GFXNumber(GRID(2,row),p,16,4,GRIDSIZE,isPC ? DBGC_HIGHLIGHT:DBGC_ADDRESS, // Display address / highlight / breakpoint isBrk ? 0xF00 : -1); opc = CPUReadMemory(p);p = (p + 1) & 0xFFFF; // Read opcode. if ((opc & 0x80) != 0) { opr = CPUReadMemory(p);p = (p + 1) & 0xFFFF; // Read operand. } strcpy(buffer,__mnemonics[opc]); // Set the mnemonic. if (buffer[0] == '\0') sprintf(buffer,"db %02x",opc); // Make up one if required. char *ph = strchr(buffer,'#'); // Insert operand if (ph != NULL) { sprintf(buffer2,"%02x",opr); *ph++ = buffer2[0]; *ph++ = buffer2[1]; } GFXString(GRID(7,row),buffer,GRIDSIZE,isPC ? DBGC_HIGHLIGHT:DBGC_DATA,-1); // Print the mnemonic } if (showDisplay == 0) return; int xSize = 5; int ySize = 5; SDL_Rect rc; rc.w = 8 * 16 * xSize; // 8 x 8 font, 16 x 8 text rc.h = 8 * 8 * ySize; rc.x = WIN_WIDTH/2-rc.w/2;rc.y = WIN_HEIGHT-64-rc.h; SDL_Rect rc2 = rc; rc2.x -= 10;rc2.y -= 10;rc2.w += 20;rc2.h += 20; GFXRectangle(&rc2,0xFFF); rc2.x += 2;rc2.y += 2;rc2.w -= 4;rc2.h -= 4; SDL_Rect rcPixel;rcPixel.w = xSize;rcPixel.h = ySize; GFXRectangle(&rc2,0x13F & 0x000); for (int x = 0;x < 16;x++) { for (int y = 0;y < 8;y++) { BYTE8 ch = HWIGetVideoMemory()[x + y * 16]; for (int y1 = 0;y1 < 8;y1++) { BYTE8 b = __bitmapFont[ch * 8 + y1]; rcPixel.x = (x * 8 * xSize)+rc.x; rcPixel.y = (y * 8 + y1) * ySize + rc.y; while (b != 0) { if (b & 0x80) GFXRectangle(&rcPixel,0xFFF); b = (b << 1) & 0xFF; rcPixel.x += xSize; } } } } }
int CFEAT::k1DC0LElement (int nE, CVector<int>& nVNList, CMatrix<double>& dMk,CMatrix<double> & dTF) // ================================================================== // Function: Generates k for the 1D-C0 linear element // Input: Element number // Output: Element stiffness matrix in dMk // a return value of 0 means no error // ================================================================== { CVector<float> fVMatP(NUMEP); // young's modulus CVector<float> fVCoords1(PDIM); // nodal coordinates (node 1) CVector<float> fVCoords2(PDIM); // nodal coordinates (node 2) CVector<float> fVCoords3(PDIM); // nodal coordinates (node 3) CVector<float> fVCoords4(PDIM); // nodal coordinates (node 4) CVector<int> nVN(NUMENODES); CElement::type VC; // get element data m_ElementData(nE).GetMaterialProperty(fVMatP); m_ElementData(nE).GetNodes(nVN); m_ElementData(nE).Getstressstrain(VC); m_NodalData(nVN(1)).GetCoords (fVCoords1); m_NodalData(nVN(2)).GetCoords (fVCoords2); m_NodalData(nVN(3)).GetCoords (fVCoords3); m_NodalData(nVN(4)).GetCoords (fVCoords4); float x = 0.0f; CGaussQuad GQ; // for numerical integration via G-Q const int NORDER = 2; // numerical integration order const int NGP = 2; // # of G-Q points CVector<double> PHI(NUMENODES); // shape functions CVector<double> DPHDXI(NUMENODES); // derivatives of shape functions CVector<double> DPHDX(NUMENODES); // derivatives of shape functions (wrt x) CMatrix<double> DJAC(NORDER,NORDER); CMatrix<double> DJACIN(NORDER,NORDER); CMatrix<double> DO(3,4),DN(4,8),DBT(8,3),DT(8,3),DK(8,8),DTE(8,1),DTI(3,3),DTT(8,3); double delta=0.0,DETJAC; float T; DB.Set(0.0); DN.Set(0.0); DO.Set(0.0); DBT.Set(0.0); DT.Set(0.0); DEO.Set(0.0); DTE.Set(0.0); DD.Set(0.0); DK.Set(0.0); DTI.Set(0.0); DTT.Set(0.0); int i, j; for (int NG=1; NG <= NGP; NG++) { for (int NN=1; NN<=NGP; NN++) { // gauss-point and weight double PXI = GQ.GetLocation (NORDER, NG); double PNI = GQ.GetLocation (NORDER, NN); double WG1 = GQ.GetWeight (NORDER, NG); double WG2 = GQ.GetWeight (NORDER, NN); // shape functions PHI(1)=0.25*(1.0-PXI)*(1.0-PNI); PHI(2)=0.25*(1.0+PXI)*(1.0-PNI); PHI(3)=0.25*(1.0+PXI)*(1.0+PNI); PHI(4)=0.25*(1.0-PXI)*(1.0+PNI); double a=fVCoords1(1)-fVCoords2(1)+fVCoords3(1)-fVCoords4(1); double a1=-fVCoords1(1)+fVCoords2(1)+fVCoords3(1)-fVCoords4(1); double a2=-fVCoords1(1)-fVCoords2(1)+fVCoords3(1)+fVCoords4(1); double b=fVCoords1(2)-fVCoords2(2)+fVCoords3(2)-fVCoords4(2); double b1=-fVCoords1(2)+fVCoords2(2)+fVCoords3(2)-fVCoords4(2); double b2=-fVCoords1(2)-fVCoords2(2)+fVCoords3(2)+fVCoords4(2); // compute jacobian DJAC(1,1)=(PNI*a+a1)*0.25; DJAC(1,2)=(PNI*b+b1)*0.25; DJAC(2,1)=(PXI*a+a2)*0.25; DJAC(2,2)=(PXI*b+b2)*0.25; DETJAC=DJAC(1,1)*DJAC(2,2)-DJAC(1,2)*DJAC(2,1); /*if(DETJAC==0) ErrorHandler(INVERSEERROR);*/ // compute inverse of jacobian DJACIN(1,1)=DJAC(2,2)/DETJAC; DJACIN(2,2)=DJAC(1,1)/DETJAC; if(DJAC(1,2)!=0) DJACIN(1,2)=-DJAC(1,2)/DETJAC; else DJACIN(1,2)=DJAC(1,2)/DETJAC; if(DJAC(2,1)!=0) DJACIN(2,1)=-DJAC(2,1)/DETJAC; else DJACIN(2,1)=DJAC(2,1)/DETJAC; DO(1,1)=DJACIN(1,1); DO(1,2)=DJACIN(1,2); DO(2,3)=DJACIN(2,1); DO(2,4)=DJACIN(2,2); DO(3,1)=DJACIN(2,1); DO(3,2)=DJACIN(2,2); DO(3,3)=DJACIN(1,1); DO(3,4)=DJACIN(1,2); DN(1,1)=DN(3,2)= -(1-PNI); DN(1,3)=DN(3,4)= -DN(1,1); DN(1,5)=DN(3,6)= (1+PNI); DN(1,7)=DN(3,8)= -DN(1,5); DN(2,1)=DN(4,2)= -(1-PXI); DN(2,3)=DN(4,4)= -(1+PXI); DN(2,5)=DN(4,6)= -DN(2,3); DN(2,7)=DN(4,8)= -DN(2,1); if (VC==0) { DD(1,1)=DD(2,2)=fVMatP(2)/(1-fVMatP(3)*fVMatP(3)); DD(1,2)=DD(2,1)=fVMatP(3)*fVMatP(2)/(1-fVMatP(3)*fVMatP(3)); DD(3,3)=0.5*(1-fVMatP(3))*fVMatP(2)/(1-fVMatP(3)*fVMatP(3)); } else { DD(1,1)=DD(2,2)=(1-fVMatP(3))*fVMatP(2)/((1+fVMatP(3))*(1-2*fVMatP(3))); DD(1,2)=DD(2,1)=fVMatP(3)*fVMatP(2)/((1+fVMatP(3))*(1-2*fVMatP(3))); DD(3,3)=(0.5-fVMatP(3))*fVMatP(2)/((1+fVMatP(3))*(1-2*fVMatP(3))); } Multiply(DO,DN,DB); for(int h=1; h<=4; h++) { m_NodalData(nVN(h)).GetTemp(T); delta+=PHI(h)*T; } if(VC==0) DEO(1,1)=DEO(2,1)=fVMatP(4)*delta; else DEO(1,1)=DEO(2,1)=(1+fVMatP(3))*fVMatP(4)*delta; // compute stiffness at gauss point for (i=1; i <= 3; i++) for (j=1; j <= 3; j++) DTI(i,j) += WG1*WG2*DD(i,j)*fVMatP(1)*DETJAC; Transpose(DB,DBT); Multiply(DBT,DTI,DT); Multiply(DBT,DD,DTT); Multiply(DTT,DEO,DTE); Multiply(DT,DB,DK); for(int k=1; k<=2*NUMENODES; k++) { dTF(k,1) += WG1*WG2*DTE(i,1)*fVMatP(1); for(int l=1; l<=2*NUMENODES; l++) dMk(k,l)+=DK(k,l); } } } // debug? return 0; }