| 1 |
/************************************************************************* |
| 2 |
* * |
| 3 |
* Vega FEM Simulation Library Version 3.1 * |
| 4 |
* * |
| 5 |
* "volumetricMesh" library , Copyright (C) 2007 CMU, 2009 MIT, 2016 USC * |
| 6 |
* All rights reserved. * |
| 7 |
* * |
| 8 |
* Code author: Jernej Barbic * |
| 9 |
* http://www.jernejbarbic.com/code * |
| 10 |
* * |
| 11 |
* Research: Jernej Barbic, Fun Shing Sin, Daniel Schroeder, * |
| 12 |
* Doug L. James, Jovan Popovic * |
| 13 |
* * |
| 14 |
* Funding: National Science Foundation, Link Foundation, * |
| 15 |
* Singapore-MIT GAMBIT Game Lab, * |
| 16 |
* Zumberge Research and Innovation Fund at USC * |
| 17 |
* * |
| 18 |
* This library is free software; you can redistribute it and/or * |
| 19 |
* modify it under the terms of the BSD-style license that is * |
| 20 |
* included with this library in the file LICENSE.txt * |
| 21 |
* * |
| 22 |
* This library is distributed in the hope that it will be useful, * |
| 23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file * |
| 25 |
* LICENSE.TXT for more details. * |
| 26 |
* * |
| 27 |
*************************************************************************/ |
| 28 |
|
| 29 |
#include "generateInterpolationMatrix.h" |
| 30 |
|
| 31 |
void GenerateInterpolationMatrix::generate(int numTargetLocations, int numElementVertices, const int * vertices, const double * weights, SparseMatrix ** A, int numSourceVertices) |
| 32 |
{ |
| 33 |
SparseMatrixOutline outline(3*numTargetLocations); |
| 34 |
|
| 35 |
for(int vtx=0; vtx<numTargetLocations; vtx++) |
| 36 |
{ |
| 37 |
for(int i=0; i<numElementVertices; i++) |
| 38 |
{ |
| 39 |
for(int j=0; j<3; j++) |
| 40 |
outline.AddEntry(3*vtx+j, 3*vertices[numElementVertices*vtx+i]+j, weights[numElementVertices*vtx+i]); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
int numColumns = outline.GetNumColumns(); |
| 45 |
for(int i=numColumns; i<3*numSourceVertices; i++) |
| 46 |
outline.AddEntry(0, i, 0.0); |
| 47 |
|
| 48 |
*A = new SparseMatrix(&outline); |
| 49 |
} |
| 50 |
|