public void InitializeCSR() { // list non-anchored nodes and give them sequential ids activeNodes = nodes.FindAll(nd => !nd.anchored); int id = 0; foreach (Node nd in activeNodes) { nd.altId = id++; } // in each node make a list of elements to which it belongs foreach (Element elem in elems) { foreach (Node nd in elem.vertices) { nd.AddElem(elem); } } // find neighbour nodes Parallel.ForEach(nodes, nd => nd.InferConnectivityInformation()); // count total number of neighbours in all nodes int count = 0; foreach (Node nd in activeNodes) { count += nd.neighbors.Count; } // allocate CSR // each neighbor contributes 3 rows and 3 columns to CSR matrix, so nnz = count * 9 // the size of the matrix is (number of active nodes)*(3 coordinates) csr = new CSR_System(activeNodes.Count * 3, count * 9); // 3) create CSR indices count = 0; foreach (Node nd in activeNodes) { int row_nnz = nd.CreateCSRIndices(count, csr.cols); csr.rows[nd.altId * 3] = count; csr.rows[nd.altId * 3 + 1] = count + row_nnz; csr.rows[nd.altId * 3 + 2] = count + row_nnz * 2; count += row_nnz * 3; } }
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Stopwatch sw = new Stopwatch(); // initialize Paralution CSR_System.initParalution(); do { mre.WaitOne(Timeout.Infinite); sw.Restart(); model.AssembleLinearSystem(); // assemble msAssemble = sw.ElapsedMilliseconds; sw.Restart(); model.Solve(useGPU, useDoublePrecision); // solve sw.Stop(); msSolve = sw.ElapsedMilliseconds; backgroundWorker1.ReportProgress(0); } while (true); // stop paralution }