Example #1
0
 public SM_Edge(SM_Vertex v0, SM_Vertex v1, double k)
 {
     this.k  = k;
     this.v0 = v0; this.v1 = v1;
     row     = this.v0.idx;
     col     = this.v1.idx;
 }
Example #2
0
        private SM_Vertex TryGetVertex(int key, SortedDictionary <int, SM_Vertex> lookup)
        {
            SM_Vertex cur;

            if (!lookup.ContainsKey(key))
            {
                cur = new SM_Vertex(key);
                lookup.Add(key, cur);
            }
            else
            {
                cur = lookup[key];
            }

            return(cur);
        }
Example #3
0
        public Matrix <double> GetMassMatrix()
        {
            int             of = SM_Vertex.dof;
            int             n  = mesh.vertexCount * of;
            Matrix <double> M  = Matrix <double> .Build.Sparse(n, n, 0);

            foreach (var vertexEntry in lookup)
            {
                SM_Vertex v = vertexEntry.Value;
                for (int i = 0; i < of; i++)
                {
                    M[of * v.idx + i, of *v.idx + i] = v.mass;
                }
            }

            return(M);
        }
Example #4
0
        public void SetEdges(List <SM_Edge> edges, SortedDictionary <int, SM_Vertex> lookup)
        {
            SM_Vertex pv = TryGetVertex(p, lookup);

            pv.AddParent(this);
            SM_Vertex qv = TryGetVertex(q, lookup);

            qv.AddParent(this);
            SM_Vertex rv = TryGetVertex(r, lookup);

            rv.AddParent(this);
            SM_Edge e0 = new SM_Edge(pv, qv, kc);

            edges.Add(e0);
            SM_Edge e1 = new SM_Edge(qv, rv, kc);

            edges.Add(e1);
            SM_Edge e2 = new SM_Edge(rv, pv, kc);

            edges.Add(e2);
        }