Debian Codegraph @

src/num/aslFDAdvectionDiffusionBC.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 "aslFDAdvectionDiffusionBC.h"
25 #include "aslFDAdvectionDiffusion.h"
26 #include <aslGenerators.h>
27 #include <acl/aclGenerators.h>
28 #include <acl/acl.h>
29 #include <acl/aclHardware.h>
30 #include <math/aslTemplateVE.h>
31
32 #include <data/aslDataWithGhostNodes.h>
33 #include <acl/Kernels/aclKernel.h>
34 #include <math/aslTemplates.h>
35
36 #include <acl/Kernels/aclKernelConfigurationTemplates.h>
37 #include <math/aslDistanceFunctionAlg.h>
38
39 namespace asl
40 {
41
42 BCConstantFluxMap::BCConstantFluxMap(Data d,
43 const acl::VectorOfElements & val,
44 Data map,
45 const VectorTemplate *const t):
46 BCondWithMap(map, t),
47 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),
48 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
49 data(d),
50 value(val)
51 {
52 }
53
54 BCConstantFluxMap::~BCConstantFluxMap()
55 {
56 }
57
58
59 void BCConstantFluxMap::init()
60 {
61 acl::ExpressionContainer kk;
62
63 unsigned int nd(nD(data->getBlock())); //< number of dimmentions
64 unsigned int nc(data->getEContainer().size()); // number of components
65
66 auto dataX(generateDCFullSafe(data));
67
68 initMapInfrastructure(kk);
69
70 acl::TypeID type(getElementType(data->getEContainer()));
71 acl::TypeID typeI(acl::TYPE_SELECT[type]);
72
73 TemplateVE dataTVE(*dataX, *templ);
74 kk << dataTVE.initValues;
75
76 auto normal(generateVEPrivateVariable(nd,type));
77 auto area(generateVEPrivateVariable(1,type));
78 auto sw(generateVEPrivateVariable(1,type));
79 auto swc(generateVEPrivateVariable(1,type));
80 auto sna(generateVEPrivateVariable(1,type));
81 auto sna1mx(generateVEPrivateVariable(1,type));
82 auto snaxc(generateVEPrivateVariable(nc,type));
83 auto isBoundary(generateVEPrivateVariable(1,typeI));
84
85 unsigned int nDir(templ->vectors.size());
86
87 kk << (sw = acl::generateVEConstant(0.));
88 kk << (swc = acl::generateVEConstant(0.));
89 kk << (gcNormalize(normal));
90 // kk << gcBoundaryAreaPerGhostPoint(*mapTVE, area);
91
92 // TemplateVE mSTVE(mapTVE->values*.5+catN(mapTVE->getValue(0),nDir)*.5 ,
93 // *mapTVE->vectorTemplate);
94 // kk << gcBoundaryArea(mSTVE, area);
95 kk << gcBoundaryArea(*mapTVE, area);
96
97 for(unsigned int i(1); i < nDir; ++i)
98 {
99 kk << (isBoundary = isComputationNode(i));
100 kk << (sw += select(acl::generateVEConstant(templ->laplasCoefs[i]),
101 isBoundary,type));
102 kk << (swc += select(dataTVE.getValue(i) * templ->laplasCoefs[i],
103 isBoundary,type));
104 }
105 auto vLocal((swc+sw*value)/sw);
106 // auto vLocal((swc+area*value)/sw);
107 // auto vLocal(area*.25);
108 // kk << (acl::assignmentSafe(data->getEContainer(), vLocal));
109 kk << (acl::assignmentSafe(data->getEContainer(),
110 select(dataTVE.getValue(0), vLocal, isGhostNode(0), type)));
111 //
112 /* kernel->addExpression(acl::elementOperators::
113 ifElse(acl::elementOperators::any((isGhostNode() &&
114 map->getEContainer() > -.9999)[0]),
115 kk.expression,
116 {} ));
117 */
118 (*kernel)<<kk;
119 kernel->setup();
120 }
121
122 void BCConstantFluxMap::execute()
123 {
124 kernel->compute();
125 }
126
127
128
129
130 SPNumMethod generateBCConstantFlux(SPFDAdvectionDiffusion nm,
131 double flux,
132 SPAbstractDataWithGhostNodes map)
133 {
134 auto a(make_shared<BCConstantFluxMap>(nm->getData()[0],
135 flux/nm->getDiffusionCoefficient(),
136 map,
137 nm->getVectorTemplate()));
138 return a;
139
140 }
141
142 } //asl