| 1 |
/* |
| 2 |
* Advanced Simulation Library <http://asl.org.il> |
| 3 |
* |
| 4 |
* Copyright 2015 Avtech Scientific <http://avtechscientific.com> |
| 5 |
* |
| 6 |
* |
| 7 |
* This file is part of Advanced Simulation Library (ASL). |
| 8 |
* |
| 9 |
* ASL is free software: you can redistribute it and/or modify it |
| 10 |
* under the terms of the GNU Affero General Public License as |
| 11 |
* published by the Free Software Foundation, version 3 of the License. |
| 12 |
* |
| 13 |
* ASL is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Affero General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Affero General Public License |
| 19 |
* along with ASL. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
|
| 24 |
#include "aslTemplateVE.h" |
| 25 |
#include "acl/acl.h" |
| 26 |
#include "acl/aclGenerators.h" |
| 27 |
#include <aslUtilities.h> |
| 28 |
|
| 29 |
using acl::VectorOfElements; |
| 30 |
using acl::Element; |
| 31 |
|
| 32 |
namespace asl |
| 33 |
{ |
| 34 |
|
| 35 |
acl::VectorOfElements cellValues(const TemplateVE & a, unsigned int iEl) |
| 36 |
{ |
| 37 |
if(iEl >= a.vto->elementaryCells.size()) |
| 38 |
errorMessage("cellValues: iEl larger than the number of cells"); |
| 39 |
auto cell(a.vto->elementaryCells[iEl]); |
| 40 |
unsigned int nv(cell.getSize()); |
| 41 |
|
| 42 |
acl::VectorOfElements valI(nv); |
| 43 |
for(unsigned int ii(0); ii < nv; ++ii) |
| 44 |
valI[ii] = subVE(a.values,cell[ii])[0]; |
| 45 |
|
| 46 |
return valI; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
VectorOfElements gradient(const TemplateVE & a, unsigned int iEl) |
| 51 |
{ |
| 52 |
return a.vto->cellGradient(a.values, iEl); |
| 53 |
} |
| 54 |
|
| 55 |
vector<Element> gcGradientAllCells(const TemplateVE & a, |
| 56 |
vector<VectorOfElements> & values) |
| 57 |
{ |
| 58 |
unsigned int nCells(a.vto->elementaryCells.size()); |
| 59 |
unsigned int nDim(nD(*a.vectorTemplate)); |
| 60 |
auto type(getElementType(a.values)); |
| 61 |
|
| 62 |
values.resize(nCells); |
| 63 |
for(unsigned int i(0); i < nCells; ++i) |
| 64 |
copy(acl::generateVEPrivateVariable(nDim, type),values[i]); |
| 65 |
|
| 66 |
acl::VectorOfElements code; |
| 67 |
copy(values[0] = gradient(a, 0), code); |
| 68 |
for(unsigned int i(1); i < nCells; ++i) |
| 69 |
copy(cat(code, values[i] = gradient(a, i)), |
| 70 |
code); |
| 71 |
|
| 72 |
return code; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
}// asl |