/*************************************************************************** * Copyright (C) 2003-2004 by David Saxton * * david@bluehaze.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "element.h" #include "elementset.h" #include #include Element::Element() { b_status = false; p_A = 0l; p_eSet = 0l; p_b = 0l; b_componentDeleted = false; b_eSetDeleted = true; for ( int i=0; i<8; i++ ) p_cnode[i] = 0l; resetCurrents(); for ( int i=0; i<4; i++ ) p_cbranch[i] = 0l; m_numCBranches = 0; m_numCNodes = 0; } Element::~ Element() { } void Element::resetCurrents() { for ( int i=0; i<8; i++ ) m_cnodeI[i] = 0.0; } void Element::setElementSet( ElementSet *c ) { assert(!b_componentDeleted); assert(!p_eSet); if (!c) return elementSetDeleted(); b_eSetDeleted = false; p_eSet = c; p_A = p_eSet->matrix(); p_b = p_eSet->b(); updatetqStatus(); } void Element::componentDeleted() { // assert(!b_componentDeleted); if (b_componentDeleted) { // Something strange happened here.... } if (b_eSetDeleted) return delete this; b_componentDeleted = true; b_status = false; // kdDebug() << "Element::componentDeleted(): Setting b_status to false, this="<-1)?p_eSet->cnodes()[n0]:(n0==-1?p_eSet->ground():0l); p_cnode[1] = (n1>-1)?p_eSet->cnodes()[n1]:(n1==-1?p_eSet->ground():0l); p_cnode[2] = (n2>-1)?p_eSet->cnodes()[n2]:(n2==-1?p_eSet->ground():0l); p_cnode[3] = (n3>-1)?p_eSet->cnodes()[n3]:(n3==-1?p_eSet->ground():0l); updatetqStatus(); } void Element::setCBranches( const int b0, const int b1, const int b2, const int b3 ) { if ( !p_eSet ) { // cerr << "Element::setCBranches: can't set branches without circuit!"<-1)?p_eSet->cbranches()[b0]:0l; p_cbranch[1] = (b1>-1)?p_eSet->cbranches()[b1]:0l; p_cbranch[2] = (b2>-1)?p_eSet->cbranches()[b2]:0l; p_cbranch[3] = (b3>-1)?p_eSet->cbranches()[b3]:0l; updatetqStatus(); } bool Element::updatetqStatus() { // First, set status to false if all nodes in use are ground b_status = false; for ( int i=0; iisGround:false; } // Set status to false if any of the nodes are not set for ( int i=0; i