#include "stdafx.h" #include #include #include "bv_problem.h" #include "femm.h" #include "xyplot.h" #include "belaviewDoc.h" #include "belaviewView.h" #include "MainFrm.h" #include "maskprogress.h" #include "lua.h" #include "spars.h" extern BOOL bLinehook; extern CLuaConsoleDlg *LuaConsole; // #define SIMPLE #ifdef SIMPLE BOOL CbelaviewDoc::MakeMask() { // Good placeholder mask generator // This gives a valid mask that butts right up against the // selected region. This mask yields the same results as the // Coulomb virtual work method. int i,j; for(i=0;ibw) bw=d; } } bw++; L.Create(NumNodes,bw); // if the problem is axisymmetric, does the selection lie along r=0? if(ProblemType==1) { for(i=0;i0) { CComplex *p; int npts; p=(CComplex *)calloc(nodelist.GetSize(),sizeof(CComplex)); for(i=0,npts=0;i=0) { p[npts]=nodelist[i].CC(); npts++; } if(npts>0) for(i=0;i0){ p[j]=p[npts]; j=npts; } else{ j=npts; i=NumNodes; } } free(p); } for(i=0;iToOutput(outmsg); } else{ outmsg ="The selected region is invalid. A valid selection\n"; outmsg+="cannot abut a region which is not free space."; MsgBox(outmsg); } free(matflag); free(lblflag); return FALSE; } } // Each element weighted by its region's // mesh size specification; v=blocklist[meshelem[i].lbl].MaxArea; if (v<=0) v=sqrt(a); else v=sqrt(v); // build element matrix; for(j=0;j<3;j++) for(k=0;k<3;k++) Me[j][k]+=v*(p[j]*p[k]+q[j]*q[k])/a; // process any prescribed nodal values; // doing it here saves a lot of time. for(j=0;j<3;j++) { if(L.V[n[j]]>=0) { for(k=0;k<3;k++) { if(j!=k){ be[k]-=Me[k][j]*L.V[n[j]]; Me[k][j]=0; Me[j][k]=0; } } be[j]=L.V[n[j]]*Me[j][j]; } } // combine block matrices into global matrices; for (j=0;j<3;j++) { for (k=j;k<3;k++) if(Me[j][k]!=0) L.Put(L.Get(n[j],n[k])-Me[j][k],n[j],n[k]); L.b[n[j]]-=be[j]; } } // solve the problem; bLinehook=BuildMask; if (L.PCGSolve(FALSE)==FALSE) return FALSE; bLinehook=FALSE; // Process the results to get one row of elements // that runs down the center of the gap away from boundaries. for(i=0;i0.5) meshnode[i].msk = 1; else meshnode[i].msk = 0; free(matflag); free(lblflag); bHasMask=TRUE; return TRUE; } #endif BOOL CbelaviewDoc::IsKosher(int k) { // If: // 1) this is an axisymmetric problem; // 2) the selected geometry lies along the r=0 axis, and // 3) we have a node on the r=0 axis that we are trying to determine // if we should set to zero. // This routine determines whether the node is at the extents of // the r=0 domain (or lies at a break in some sub-interval). // // Returns TRUE if it is OK to define the node as zero; if((ProblemType==0) || (meshnode[k].x>1.e-6)) return TRUE; int i,j,n; int score=0; for(i=0;i1) return FALSE; } } } return TRUE; }