#include "stdafx.h" #include #include #include "problem.h" #include "femm.h" #include "xyplot.h" #include "femmviewDoc.h" #include "femmviewView.h" #include "MainFrm.h" #include "maskprogress.h" #include "lua.h" #include "spars.h" extern BOOL bLinehook; extern CLuaConsoleDlg *LuaConsole; // #define SIMPLE #ifdef SIMPLE BOOL CFemmviewDoc::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;i=0) lblflag[i]=1; } // Determine which nodal values should be fixed // and what values they should be fixed at; 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); } // build up element matrices; 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; } } switch(WeightingScheme) { case 1: // all elements evenly weighted v=1; break; case 2: // weights each element with the sqrt of its own area; v=sqrt(a); break; case 3: // determine a weighting for the element // based on an error measure; for(j=0,bsq=0,dbsq=0;j<3;j++) { dbsq+=Re((meshelem[i].B1-meshelem[i].b1[j])* conj(meshelem[i].B1-meshelem[i].b1[j]) + (meshelem[i].B2-meshelem[i].b2[j])* conj(meshelem[i].B2-meshelem[i].b2[j])); bsq +=Re(meshelem[i].B1*conj(meshelem[i].B1) + meshelem[i].B2*conj(meshelem[i].B2)); } if(bsq!=0) v=dbsq/bsq; else(v=1); break; case 4: // determine a weighting for the element // based on an error measure; for(k=0,dbsq=0,bsq=0;k<3;k++) for(j=0;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; for(i=0;i0.5) meshnode[i].msk=1; else meshnode[i].msk=0; break; default: meshnode[i].msk = L.V[i]; break; } } free(matflag); free(lblflag); bHasMask=TRUE; return TRUE; } #endif BOOL CFemmviewDoc::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; }