Debian Codegraph @

src/math/aslIndex2Position.cxx

raw
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 "aslIndex2Position.h"
25 #include <acl/aclGenerators.h>
26 #include <acl/acl.h>
27 #include <acl/DataTypes/aclIndexExt.h>
28 #include <acl/DataTypes/aclConstant.h>
29
30 namespace asl
31 {
32 Index2PositionDiscreteACL::Index2PositionDiscreteACL(const Block & b, bool putSize):
33 initPosition(b.getSize().getSize()),
34 position(acl::generateVEPrivateVariable<int>(b.getSize().getSize())),
35 positionWithInit(b.getSize().getSize())
36 {
37 unsigned int nD(b.getSize().getSize());
38 unsigned int size(putSize ? productOfElements (b.getSize()) : 0);
39 if (nD==2){
40 using namespace acl::elementOperators;
41 using acl::elementOperators::operator/;
42 positionWithInit[0] =acl::Element(new acl::IndexExt(size))/
43 acl::Element(new acl::Constant<int>(b.getSize()[1]));
44 positionWithInit[1] =acl::Element(new acl::IndexExt(size))%
45 acl::Element(new acl::Constant<int>(b.getSize()[1]));
46 copy(position=positionWithInit,initPosition);
47 }
48 if (nD==3){
49 using namespace acl::elementOperators;
50 int s12(b.getSize()[1]*b.getSize()[2]);
51 using acl::elementOperators::operator/;
52 positionWithInit[0] =acl::Element(new acl::IndexExt(size))/
53 acl::Element(new acl::Constant<int>(s12));
54 positionWithInit[1] =acl::Element(new acl::IndexExt(size))%
55 acl::Element(new acl::Constant<int>(s12))/
56 acl::Element(new acl::Constant<int>(b.getSize()[2]));
57 positionWithInit[2] =acl::Element(new acl::IndexExt(size))%
58 acl::Element(new acl::Constant<int>(s12))%
59 acl::Element(new acl::Constant<int>(b.getSize()[2]));
60 copy(position=positionWithInit,initPosition);
61 }
62 }
63
64 Index2PositionACL::Index2PositionACL(const Block & b,
65 acl::TypeID type,
66 bool putSize):
67 initPosition(b.getSize().getSize()),
68 position(acl::generateVEPrivateVariable(b.getSize().getSize(),type)),
69 positionWithInit(b.getSize().getSize())
70 {
71 unsigned int nD(b.getSize().getSize());
72 unsigned int size(putSize ? productOfElements (b.getSize()) : 0);
73 if (nD==2){
74 using namespace acl::elementOperators;
75 using acl::elementOperators::operator/;
76 positionWithInit[0] =acl::Element(new acl::IndexExt(size))/
77 acl::Element(new acl::Constant<int>(b.getSize()[1]));
78 positionWithInit[1] =acl::Element(new acl::IndexExt(size))%
79 acl::Element(new acl::Constant<int>(b.getSize()[1]));
80 copy(acl::convert(type,
81 acl::generateVEConstant(b.position) +
82 acl::generateVEConstant(b.dx) *
83 acl::convert(type,positionWithInit),
84 false),
85 positionWithInit);
86 copy(position=positionWithInit, initPosition);
87 }
88 if (nD==3){
89 using namespace acl::elementOperators;
90 int s12(b.getSize()[1]*b.getSize()[2]);
91 using acl::elementOperators::operator/;
92 positionWithInit[0] =acl::Element(new acl::IndexExt(size))/
93 acl::Element(new acl::Constant<int>(s12));
94 positionWithInit[1] =acl::Element(new acl::IndexExt(size))%
95 acl::Element(new acl::Constant<int>(s12))/
96 acl::Element(new acl::Constant<int>(b.getSize()[2]));
97 positionWithInit[2] =acl::Element(new acl::IndexExt(size))%
98 acl::Element(new acl::Constant<int>(s12))%
99 acl::Element(new acl::Constant<int>(b.getSize()[2]));
100 copy(acl::convert(type,
101 acl::generateVEConstant(b.position) +
102 acl::generateVEConstant(b.dx) *
103 acl::convert(type,positionWithInit),
104 false),
105 positionWithInit);
106 copy(position=positionWithInit, initPosition);
107 }
108 }
109
110
111 }// asl