Debian Codegraph @

src/num/aslLBGKBC.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 "aslLBGKBC.h"
25
26 #include "aslLBGK.h"
27 #include "aslBasicBC.h"
28 #include <data/aslDataWithGhostNodes.h>
29 #include "acl/acl.h"
30 #include "acl/Kernels/aclKernel.h"
31 #include "acl/Kernels/aclKernelConfigurationTemplates.h"
32 #include "acl/Kernels/aclKernelMerger.h"
33 #include "acl/aclGenerators.h"
34 #include "acl/aclMath/aclVectorOfElements.h"
35 #include <algorithm>
36 #include <math/aslTemplates.h>
37 #include <aslGenerators.h>
38 #include <math/aslTemplateVE.h>
39 #include "acl/aclMath/aclMathAlg.h"
40 #include <math/aslIndex2Position.h>
41 #include <math/aslPositionFunction.h>
42
43 namespace asl
44 {
45 using acl::generateVEConstant;
46 using acl::generateVEConstantN;
47 using acl::generateVEPrivateVariable;
48
49
50 BCLBGKCommon::BCLBGKCommon(SPLBGK nm):
51 BCond(nm->getF()->getBlock(),nm->getVectorTemplate()),
52 num(nm),
53 kernels(nm->getVectorTemplate()->vectors.size()),
54 km(new acl::KernelMerger()),
55 directionGroupsShifts(nm->getVectorTemplate()->vectors.size()),
56 directionGroupsSizes(nm->getVectorTemplate()->vectors.size())
57 {
58 for(unsigned int i(0); i<kernels.size(); ++i)
59 kernels[i].reset(new acl::Kernel(acl::KERNEL_BASIC));
60 }
61
62
63 void BCLBGKCommon::sortDirections()
64 {
65 sortTwoVectors(directions, indices);
66
67 unsigned int n(directionGroupsShifts.getSize());
68 for(unsigned int i(0); i<n; ++i){
69 directionGroupsShifts[i]=std::find(directions.begin(),
70 directions.end(),
71 (int)i)-directions.begin();
72 directionGroupsSizes[i]=directions.rend()-
73 std::find(directions.rbegin(), directions.rend(), (int)i)
74 -directionGroupsShifts[i];
75 directionGroupsSizes[i]=directionGroupsSizes[i]<0 ? 0 : directionGroupsSizes[i];
76 }
77 }
78
79
80 void BCLBGKCommon::execute()
81 {
82 km->compute();
83 }
84
85
86 BCNoSlip::BCNoSlip(SPLBGK nm):
87 BCLBGKCommon(nm)
88 {}
89
90
91 void BCNoSlip::init()
92 {
93
94 unsigned int nC(directionGroupsShifts.getSize());
95 sortDirections();
96 loadIndicesToACL();
97
98 for(unsigned int i(1); i<nC; ++i ){
99 if(directionGroupsSizes[i]>0)
100 {
101 auto vGhost(subVE(num->getF()->getEContainer(), i));
102 auto vBulk(subVE(num->getF()->getEContainer(), templ->invertVectors[i]));
103 int directionShift(block.c2i(templ->vectors[i]));
104 acl::VectorOfElements internalInd(acl::generateVEIndex(directionGroupsSizes[i])+
105 directionGroupsShifts[i]);
106 (*(kernels[i]))<<(acl::excerpt(acl::excerpt(vGhost,*indicesACL)=
107 acl::excerpt(vBulk,*indicesACL+directionShift),
108 internalInd));
109 km->addKernel(kernels[i]);
110 }
111 }
112 km->setup();
113 }
114
115
116 BCConstantPressure::BCConstantPressure(SPLBGK nm, const acl::VectorOfElements & p):
117 BCLBGKCommon(nm),
118 pressure(p)
119 {}
120
121 void BCConstantPressure::init()
122 {
123
124 unsigned int nC(directionGroupsShifts.getSize());
125 sortDirections();
126 loadIndicesToACL();
127
128 for(unsigned int i(1); i<nC; ++i ){
129 if(directionGroupsSizes[i]>0)
130 {
131 acl::VectorOfElements vGhost(1);
132 vGhost[0]=num->getF()->getEContainer()[i];
133 auto internalInd(acl::generateVEIndex(directionGroupsSizes[i])+
134 directionGroupsShifts[i]);
135 (*(kernels[i]))<<(acl::excerpt(acl::excerpt(vGhost,*indicesACL)=
136 pressure,
137 internalInd));
138 km->addKernel(kernels[i]);
139 }
140 }
141 km->setup();
142 }
143
144 BCConstantVelocity::BCConstantVelocity(SPLBGK nm, const acl::VectorOfElements & v):
145 BCLBGKCommon(nm),
146 velocity(v)
147 {}
148
149 void BCConstantVelocity::init()
150 {
151
152 unsigned int nC(directionGroupsShifts.getSize());
153 sortDirections();
154 loadIndicesToACL();
155
156 for(unsigned int i(1); i<nC; ++i ){
157 if(directionGroupsSizes[i]>0)
158 {
159 auto vGhost(subVE(num->getF()->getEContainer(), i));
160 auto vBulk(subVE(num->getF()->getEContainer(), templ->invertVectors[i]));
161 int directionShift(block.c2i(templ->vectors[i]));
162 acl::VectorOfElements internalInd(acl::generateVEIndex(directionGroupsSizes[i])+
163 directionGroupsShifts[i]);
164 (*(kernels[i]))<<(acl::excerpt(acl::excerpt(vGhost,*indicesACL) =
165 acl::excerpt(vBulk,*indicesACL+directionShift) +
166 6. * (velocity * templ->vectors[i]),
167 internalInd));
168 km->addKernel(kernels[i]);
169 }
170 }
171 km->setup();
172 }
173
174 BCConstantPressureVelocity::BCConstantPressureVelocity(SPLBGK nm,
175 const acl::VectorOfElements & p,
176 const acl::VectorOfElements & v):
177 BCLBGKCommon(nm),
178 pressure(p),
179 velocity(v)
180 {}
181
182 void BCConstantPressureVelocity::init()
183 {
184
185 unsigned int nC(directionGroupsShifts.getSize());
186 sortDirections();
187 loadIndicesToACL();
188
189 for(unsigned int i(1); i<nC; ++i ){
190 if(directionGroupsSizes[i]>0)
191 {
192 auto vGhost(subVE(num->getF()->getEContainer(), i));
193 acl::VectorOfElements internalInd(acl::generateVEIndex(directionGroupsSizes[i])+
194 directionGroupsShifts[i]);
195 (*(kernels[i]))<<(acl::excerpt(acl::excerpt(vGhost,*indicesACL) =
196 pressure + 3. * (velocity * templ->vectors[i]),
197 internalInd));
198 km->addKernel(kernels[i]);
199 }
200 }
201 km->setup();
202 }
203
204
205 BCNoSlipMap::BCNoSlipMap(SPLBGK nm,
206 SPAbstractDataWithGhostNodes map):
207 BCondWithMap(map,nm->vectorTemplate),
208 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
209 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
210 num(nm)
211 {
212 }
213
214 BCNoSlipMap::~BCNoSlipMap()
215 {
216 }
217
218
219 void BCNoSlipMap::init()
220 {
221 acl::ExpressionContainer kk;
222
223 auto fX(generateDCFullSafe(num->getF()));
224
225 initMapInfrastructure(kk);
226
227 acl::TypeID type(getElementType(num->getF()->getEContainer()));
228 acl::TypeID typeI(acl::TYPE_SELECT[type]);
229
230 auto isBoundary(generateVEPrivateVariable(1,typeI));
231
232 unsigned int nDir(mapTVE->vectorTemplate->vectors.size());
233 auto & block(fX->getBlock());
234
235 for(unsigned int i(1); i < nDir; ++i)
236 {
237 kk << (isBoundary = isGhostNode(0) && isComputationNode(i));
238
239 auto vGhost(subVE(fX->getEContainer(), i));
240 int directionShift(block.c2i(templ->vectors[i]));
241 auto vBulk(subVE(fX->getEContainer(),
242 templ->invertVectors[i]));
243 vBulk[0] = acl::generateShiftedElement(vBulk[0],directionShift);
244 kk << (acl::assignmentSafe(vGhost, select(vGhost, vBulk, isBoundary, type)));
245 }
246
247 kernel->addExpression(acl::elementOperators::
248 ifElse(acl::elementOperators::any((map->getEContainer() <= 0 &&
249 map->getEContainer() > -.9999)[0]),
250 kk.expression,
251 {} ));
252
253 kernel->setup();
254 }
255
256
257 void BCNoSlipMap::execute()
258 {
259 kernel->compute();
260 }
261
262 BCVelocityMap::BCVelocityMap(SPLBGK nm,
263 SPPositionFunction v,
264 SPAbstractDataWithGhostNodes map):
265 BCondWithMap(map,nm->vectorTemplate),
266 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
267 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
268 num(nm),
269 velocity(v)
270 {
271 }
272
273 BCVelocityMap::BCVelocityMap(SPLBGK nm,
274 SPPositionFunction v,
275 SPAbstractDataWithGhostNodes map,
276 SPAbstractDataWithGhostNodes computationalDomain):
277 BCondWithMap(map,computationalDomain,nm->vectorTemplate),
278 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
279 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
280 num(nm),
281 velocity(v)
282 {
283 }
284
285 BCVelocityMap::~BCVelocityMap()
286 {
287 }
288
289
290 void BCVelocityMap::init()
291 {
292 acl::ExpressionContainer kk;
293
294 auto fX(generateDCFullSafe(num->getF()));
295
296 initMapInfrastructure(kk);
297 acl::TypeID type(getElementType(num->getF()->getEContainer()));
298 acl::TypeID typeI(acl::TYPE_SELECT[type]);
299
300 auto isBoundary(generateVEPrivateVariable(1,typeI));
301
302 unsigned int nDir(mapTVE->vectorTemplate->vectors.size());
303 auto & block(fX->getBlock());
304 unsigned int nDim(nD(block));
305 asl::Index2PositionACL i2p(block,type);
306 kk << i2p.initPosition;
307
308 auto coef(generateVEPrivateVariable(1,type));
309 auto rho(generateVEPrivateVariable(1,type));
310 auto mom(generateVEPrivateVariable(nDim,type));
311
312 kk << (coef = generateVEConstant(0.))
313 << (rho = generateVEConstant(0.))
314 << (mom = generateVEConstantN(nDim,0.));
315 for(unsigned int i(1); i < nDir; ++i)
316 {
317 kk << (isBoundary = isComputationNode(i) );
318 int directionShift(block.c2i(templ->vectors[i]));
319 auto vBulk(subVE(fX->getEContainer(),
320 templ->invertVectors[i]));
321 vBulk[0] = acl::generateShiftedElement(vBulk[0],directionShift);
322 auto w(templ->quasiparticlesCoefs[i]);
323 kk << (coef += select(generateVEConstant(0.), generateVEConstant(w), isBoundary, type));
324 kk << (rho += select(generateVEConstant(0.), vBulk * w, isBoundary, type));
325 }
326 kk << (rho/=coef);
327 kk << (mom = velocity->value(i2p.position)*rho);
328
329 for(unsigned int i(1); i < nDir; ++i)
330 {
331 kk << (isBoundary = isGhostNode(0) && isComputationNode(i) );
332
333 auto vGhost(subVE(fX->getEContainer(), i));
334 kk << (acl::assignmentSafe(vGhost,
335 select(vGhost,
336 rho + mom * templ->vectors[i] * 3.,
337 isBoundary,
338 type)));
339 }
340
341 kernel->addExpression(acl::elementOperators::
342 ifElse(acl::elementOperators::any((map->getEContainer() <= 0 &&
343 map->getEContainer() > -.9999)[0]),
344 kk.expression,
345 {} ));
346
347 kernel->setup();
348 }
349
350
351 void BCVelocityMap::execute()
352 {
353 kernel->compute();
354 }
355
356 BCConstantPressureVelocityMap::BCConstantPressureVelocityMap(SPLBGK nm,
357 acl::VectorOfElements p,
358 SPAbstractDataWithGhostNodes map):
359 BCondWithMap(map,nm->vectorTemplate),
360 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
361 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
362 num(nm),
363 pressure(p),
364 velocity(generateVEConstantN(nD(map->getBlock()),0.))
365 {
366 }
367
368 BCConstantPressureVelocityMap::BCConstantPressureVelocityMap(SPLBGK nm,
369 acl::VectorOfElements p,
370 acl::VectorOfElements v,
371 SPAbstractDataWithGhostNodes map):
372 BCondWithMap(map,nm->vectorTemplate),
373 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
374 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
375 num(nm),
376 pressure(p),
377 velocity(v)
378 {
379 }
380
381 BCConstantPressureVelocityMap::~BCConstantPressureVelocityMap()
382 {
383 }
384
385
386 void BCConstantPressureVelocityMap::init()
387 {
388 acl::ExpressionContainer kk;
389
390 auto fX(generateDCFullSafe(num->getF()));
391
392 initMapInfrastructure(kk);
393 acl::TypeID type(getElementType(num->getF()->getEContainer()));
394 acl::TypeID typeI(acl::TYPE_SELECT[type]);
395
396 auto isBoundary(generateVEPrivateVariable(1,typeI));
397
398 unsigned int nDir(mapTVE->vectorTemplate->vectors.size());
399
400 for(unsigned int i(1); i < nDir; ++i)
401 {
402 kk << (isBoundary = isGhostNode(0) && isComputationNode(i) );
403 acl::VectorOfElements fEq(1);
404 if (num->getCompressible())
405 acl::copy(pressure +
406 3. * pressure * (velocity * templ->vectors[i]) +
407 4.5 * pressure * (velocity * templ->vectors[i]) * (velocity * templ->vectors[i]) -
408 1.5 * pressure * (velocity*velocity),
409 fEq);
410 else
411 acl::copy(pressure +
412 3. * velocity * templ->vectors[i]+
413 4.5 * (velocity * templ->vectors[i]) * (velocity * templ->vectors[i]) -
414 1.5 * (velocity*velocity),
415 fEq);
416
417 auto vGhost(subVE(fX->getEContainer(), i));
418 kk << (acl::assignmentSafe(vGhost,
419 select(vGhost,
420 fEq,
421 isBoundary,
422 type)));
423 }
424
425 kernel->addExpression(acl::elementOperators::
426 ifElse(acl::elementOperators::any((map->getEContainer() <= 0 &&
427 map->getEContainer() > -.9999)[0]),
428 kk.expression,
429 {} ));
430
431 kernel->setup();
432 }
433
434
435 void BCConstantPressureVelocityMap::execute()
436 {
437 kernel->compute();
438 }
439
440
441 BCTransportLimitedDepositionMap::
442 BCTransportLimitedDepositionMap(SPLBGK nm,
443 acl::VectorOfElements p,
444 acl::VectorOfElements lF,
445 SPAbstractDataWithGhostNodes map):
446 BCondWithMap(map,nm->vectorTemplate),
447 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
448 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
449 num(nm),
450 p0(p),
451 limitingFactor(lF)
452 {
453 }
454
455 BCTransportLimitedDepositionMap::~BCTransportLimitedDepositionMap()
456 {
457 }
458
459
460 void BCTransportLimitedDepositionMap::init()
461 {
462 acl::ExpressionContainer kk;
463
464 auto fX(generateDCFullSafe(num->getF()));
465
466 initMapInfrastructure(kk);
467 acl::TypeID type(getElementType(num->getF()->getEContainer()));
468 acl::TypeID typeI(acl::TYPE_SELECT[type]);
469
470 auto isBoundary(generateVEPrivateVariable(1,typeI));
471
472 unsigned int nDir(mapTVE->vectorTemplate->vectors.size());
473 auto & block(fX->getBlock());
474 asl::Index2PositionACL i2p(block,type);
475 kk << i2p.initPosition;
476
477 auto coef(generateVEPrivateVariable(1,type));
478 auto rho(generateVEPrivateVariable(1,type));
479
480 kk << (coef = generateVEConstant(0.))
481 << (rho = generateVEConstant(0.));
482
483 for(unsigned int i(1); i < nDir; ++i)
484 {
485 kk << (isBoundary = isComputationNode(i) );
486 int directionShift(block.c2i(templ->vectors[i]));
487 auto vBulk(subVE(fX->getEContainer(),
488 templ->invertVectors[i]));
489 vBulk[0] = acl::generateShiftedElement(vBulk[0],directionShift);
490 auto w(templ->quasiparticlesCoefs[i]);
491 kk << (coef += select(generateVEConstant(0.), generateVEConstant(w), isBoundary, type));
492 kk << (rho += select(generateVEConstant(0.), vBulk * w, isBoundary, type));
493 }
494
495 for(unsigned int i(1); i < nDir; ++i)
496 {
497 kk << (isBoundary = isGhostNode(0) && isComputationNode(i) );
498
499 auto vGhost(subVE(fX->getEContainer(), i));
500 auto jSubl(rho-(rho-coef*p0)/(1.+coef*limitingFactor));
501 kk << (acl::assignmentSafe(vGhost,
502 select(vGhost,
503 jSubl/coef,
504 isBoundary,
505 type)));
506 }
507
508 kernel->addExpression(acl::elementOperators::
509 ifElse(acl::elementOperators::any((map->getEContainer() <= 0 &&
510 map->getEContainer() > -.9999)[0]),
511 kk.expression,
512 {} ));
513
514 kernel->setup();
515 }
516
517
518 void BCTransportLimitedDepositionMap::execute()
519 {
520 kernel->compute();
521 }
522
523 BCKineticsLimitedDepositionMap::
524 BCKineticsLimitedDepositionMap(SPLBGK nm,
525 acl::VectorOfElements p,
526 acl::VectorOfElements lF,
527 acl::VectorOfElements b,
528 SPAbstractDataWithGhostNodes map):
529 BCondWithMap(map,nm->vectorTemplate),
530 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
531 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
532 num(nm),
533 p0(p),
534 limitingFactor(lF),
535 beta(b)
536 {
537 }
538
539 BCKineticsLimitedDepositionMap::~BCKineticsLimitedDepositionMap()
540 {
541 }
542
543
544 void BCKineticsLimitedDepositionMap::init()
545 {
546 acl::ExpressionContainer kk;
547
548 auto fX(generateDCFullSafe(num->getF()));
549
550 initMapInfrastructure(kk);
551 acl::TypeID type(getElementType(num->getF()->getEContainer()));
552 acl::TypeID typeI(acl::TYPE_SELECT[type]);
553
554 auto isBoundary(generateVEPrivateVariable(1,typeI));
555
556 unsigned int nDir(mapTVE->vectorTemplate->vectors.size());
557 auto & block(fX->getBlock());
558 asl::Index2PositionACL i2p(block,type);
559 kk << i2p.initPosition;
560
561 auto coef(generateVEPrivateVariable(1,type));
562 auto rho(generateVEPrivateVariable(1,type));
563
564 kk << (coef = generateVEConstant(0.))
565 << (rho = generateVEConstant(0.));
566
567 for(unsigned int i(1); i < nDir; ++i)
568 {
569 kk << (isBoundary = isComputationNode(i) );
570 int directionShift(block.c2i(templ->vectors[i]));
571 auto vBulk(subVE(fX->getEContainer(),
572 templ->invertVectors[i]));
573 vBulk[0] = acl::generateShiftedElement(vBulk[0],directionShift);
574 auto w(templ->quasiparticlesCoefs[i]);
575 kk << (coef += select(generateVEConstant(0.), generateVEConstant(w), isBoundary, type));
576 kk << (rho += select(generateVEConstant(0.), vBulk * w, isBoundary, type));
577 }
578
579 for(unsigned int i(1); i < nDir; ++i)
580 {
581 kk << (isBoundary = isGhostNode(0) && isComputationNode(i) );
582
583 auto vGhost(subVE(fX->getEContainer(), i));
584 auto jSubl(rho-beta*(rho/coef-p0)/(1.+limitingFactor));
585 kk << (acl::assignmentSafe(vGhost,
586 select(vGhost,
587 jSubl/coef,
588 isBoundary,
589 type)));
590 }
591
592 kernel->addExpression(acl::elementOperators::
593 ifElse(acl::elementOperators::any((map->getEContainer() <= 0 &&
594 map->getEContainer() > -.9999)[0]),
595 kk.expression,
596 {} ));
597
598 kernel->setup();
599 }
600
601
602 void BCKineticsLimitedDepositionMap::execute()
603 {
604 kernel->compute();
605 }
606
607 ComputeSurfaceFluxMap::ComputeSurfaceFluxMap(SPLBGK nm,
608 SPDataWithGhostNodesACLData fF,
609 SPAbstractDataWithGhostNodes map):
610 BCondWithMap(map,nm->vectorTemplate),
611 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)), //< Important _BASIC has better performance
612 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
613 num(nm),
614 fluxField(fF)
615 {
616 }
617
618 ComputeSurfaceFluxMap::~ComputeSurfaceFluxMap()
619 {
620 }
621
622
623 void ComputeSurfaceFluxMap::init()
624 {
625 acl::ExpressionContainer kk;
626
627 auto fX(generateDCFullSafe(num->getF()));
628
629 initMapInfrastructure(kk);
630 acl::TypeID type(getElementType(num->getF()->getEContainer()));
631 acl::TypeID typeI(acl::TYPE_SELECT[type]);
632
633 auto isBoundary0(generateVEPrivateVariable(1,typeI));
634 auto isBoundaryI(generateVEPrivateVariable(1,typeI));
635
636 auto flux(generateVEPrivateVariable(1,type));
637
638 unsigned int nDir(templ->vectors.size());
639 auto & block(fX->getBlock());
640
641 kk << (flux = acl::generateVEConstant(0));
642 for(unsigned int i(1); i < nDir; ++i)
643 {
644 kk << (isBoundary0 = isGhostNode(0) && isComputationNode(i) );
645 kk << (isBoundaryI = isGhostNode(i) && isComputationNode(0) );
646
647 auto f0(subVE(fX->getEContainer(), i));
648 int directionShift(block.c2i(templ->vectors[i]));
649 auto fI(subVE(fX->getEContainer(),
650 templ->invertVectors[i]));
651 fI[0] = acl::generateShiftedElement(fI[0],directionShift);
652
653 kk << (flux += select((f0-fI)*templ->quasiparticlesCoefs[i], isBoundary0, type));
654 kk << (flux += select((fI-f0)*templ->quasiparticlesCoefs[i], isBoundaryI, type));
655 }
656
657 kk << (acl::assignmentSafe(fluxField->getEContainer(),flux));
658
659 kernel->addExpression(acl::elementOperators::
660 ifElse(acl::elementOperators::any((fabs(map->getEContainer()) < .9999)[0]),
661 kk.expression,
662 {} ));
663
664 kernel->setup();
665 }
666
667
668 void ComputeSurfaceFluxMap::execute()
669 {
670 kernel->compute();
671 }
672
673
674 ComputeSurfaceForceMap::ComputeSurfaceForceMap(SPLBGK nm,
675 SPDataWithGhostNodesACLData fF,
676 SPAbstractDataWithGhostNodes map):
677 BCondWithMap(map,nm->vectorTemplate),
678 // kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),//< Important _BASIC has better performance
679 kernel(new acl::Kernel(acl::KERNEL_BASIC)),
680 num(nm),
681 forceField(fF)
682 {
683 }
684
685
686 ComputeSurfaceForceMap::~ComputeSurfaceForceMap()
687 {
688 }
689
690
691 void ComputeSurfaceForceMap::init()
692 {
693 acl::ExpressionContainer kk;
694
695 auto fX(generateDCFullSafe(num->getF()));
696
697 initMapInfrastructure(kk);
698 acl::TypeID type(getElementType(num->getF()->getEContainer()));
699 acl::TypeID typeI(acl::TYPE_SELECT[type]);
700
701 auto isBoundary0(generateVEPrivateVariable(1,typeI));
702 auto isBoundaryI(generateVEPrivateVariable(1,typeI));
703
704 unsigned int nDir(templ->vectors.size());
705 auto & block(fX->getBlock());
706 unsigned int nDim(nD(block));
707
708
709 auto force(generateVEPrivateVariable(nDim,type));
710
711
712 kk<< (force = acl::generateVEConstantN(nDim,0));
713 for(unsigned int i(1); i < nDir; ++i)
714 {
715 kk << (isBoundary0 = isGhostNode(0) && isComputationNode(i) );
716 kk << (isBoundaryI = isGhostNode(i) && isComputationNode(0) );
717
718 auto f0(subVE(fX->getEContainer(), i));
719 int directionShift(block.c2i(templ->vectors[i]));
720 auto fI(subVE(fX->getEContainer(),
721 templ->invertVectors[i]));
722 fI[0] = acl::generateShiftedElement(fI[0],directionShift);
723 auto wc((templ->quasiparticlesCoefs[i]*AVec<double>(templ->vectors[i])));
724 kk << (force += select(acl::generateVEConstantN(nDim,0),( f0+fI-2.)*wc, isBoundary0, type));
725 kk << (force += select(acl::generateVEConstantN(nDim,0),(-f0-fI+2.)*wc, isBoundaryI, type));
726 }
727
728 kk << (acl::assignmentSafe(forceField->getEContainer(),force));
729
730 kernel->addExpression(acl::elementOperators::
731 ifElse(acl::elementOperators::any((fabs(map->getEContainer()) < .9999)[0]),
732 kk.expression,
733 {} ));
734
735 kernel->setup();
736 }
737
738
739 void ComputeSurfaceForceMap::execute()
740 {
741 kernel->compute();
742 }
743
744
745 SPBCond generateBCNoSlip(SPLBGK nm,
746 const std::vector<SlicesNames> & sl)
747 {
748 auto bc(make_shared<BCNoSlip>(nm));
749 addSlices(*bc, sl);
750 return bc;
751 }
752
753 /*
754 SPBCond generateBCNoSlipVel(SPLBGK nm,
755 const std::vector<SlicesNames> & sl)
756 {
757 unsigned int nd(nD(nm->getVectorTemplate()->vectors[0]));
758
759 return generateBCConstantValueMiddlePoint(nm->getVelocity(),
760 AVec<double>(nd,0.),
761 sl,
762 nearestNeigboursVT(nd));
763 }
764 */
765
766 SPBCond generateBCConstantVelocity(SPLBGK nm,
767 AVec<> v,
768 const std::vector<SlicesNames> & sl)
769 {
770 auto bc(make_shared<BCConstantVelocity>(nm, generateVEConstant(v)));
771 addSlices(*bc, sl);
772 return bc;
773
774 }
775
776
777 SPBCond generateBCConstantPressure(SPLBGK nm,
778 double p,
779 const std::vector<SlicesNames> & sl)
780 {
781 auto bc(make_shared<BCConstantPressure>(nm, generateVEConstant(p)));
782 addSlices(*bc, sl);
783 return bc;
784
785 }
786
787
788 SPBCond generateBCConstantPressureVelocity(SPLBGK nm,
789 double p,
790 AVec<> v,
791 const std::vector<SlicesNames> & sl)
792 {
793 auto bc(make_shared<BCConstantPressureVelocity>(nm,
794 generateVEConstant(p),
795 generateVEConstant(v)));
796 addSlices(*bc, sl);
797 return bc;
798 }
799
800
801 SPNumMethod generateBCNoSlip(SPLBGK nm,
802 SPAbstractDataWithGhostNodes map)
803 {
804 return make_shared<BCNoSlipMap>(nm,map);
805 }
806
807
808 SPNumMethod generateBCNoSlipVel(SPLBGK nm,
809 SPAbstractDataWithGhostNodes map)
810 {
811 unsigned int nd(nD(nm->getVelocity()->getBlock()));
812 return generateBCConstantValueMiddlePoint(nm->getVelocity(),
813 AVec<>(nd,0.),
814 map,
815 nm->vectorTemplate);
816 }
817
818
819 SPNumMethod generateBCNoSlipRho(SPLBGK nm,
820 SPAbstractDataWithGhostNodes map)
821 {
822 unsigned int nd(nD(nm->getVelocity()->getBlock()));
823 return generateBCConstantGradient(nm->getRho(),
824 AVec<>(nd,0.),
825 map,
826 nm->vectorTemplate);
827 }
828
829
830 SPNumMethod generateBCVelocity(SPLBGK nm,
831 SPPositionFunction v,
832 SPAbstractDataWithGhostNodes map)
833 {
834 return make_shared<BCVelocityMap>(nm,v,map);
835 }
836
837
838 SPNumMethod generateBCVelocity(SPLBGK nm,
839 SPPositionFunction v,
840 SPAbstractDataWithGhostNodes map,
841 SPAbstractDataWithGhostNodes computationalDomain)
842 {
843 return make_shared<BCVelocityMap>(nm,v,map,computationalDomain);
844 }
845
846
847 SPNumMethod generateBCVelocityVel(SPLBGK nm,
848 SPPositionFunction v,
849 SPAbstractDataWithGhostNodes map)
850 {
851 return generateBCConstantValue(nm->getVelocity(), v, map);
852 }
853
854
855 SPNumMethod generateBCConstantPressure(SPLBGK nm,
856 double p,
857 SPAbstractDataWithGhostNodes map)
858 {
859 auto bc(make_shared<BCConstantPressureVelocityMap>(nm, generateVEConstant(p), map));
860 return bc;
861
862 }
863
864
865 SPNumMethod generateBCConstantPressureVelocity(SPLBGK nm,
866 double p,
867 AVec<> v,
868 SPAbstractDataWithGhostNodes map)
869 {
870 auto bc(make_shared<BCConstantPressureVelocityMap>(nm,
871 generateVEConstant(p),
872 generateVEConstant(v),
873 map));
874 return bc;
875 }
876
877
878 SPNumMethod generateBCTransportLimitedDeposition(SPLBGK nm,
879 double p0,
880 double limitingFactor,
881 SPAbstractDataWithGhostNodes map)
882 {
883 auto bc(make_shared<BCTransportLimitedDepositionMap>(nm,
884 generateVEConstant(p0),
885 generateVEConstant(limitingFactor),
886 map));
887 return bc;
888 }
889
890
891 SPNumMethod generateBCKineticsLimitedDeposition(SPLBGK nm,
892 double p0,
893 double limitingFactor,
894 double beta,
895 SPAbstractDataWithGhostNodes map)
896 {
897 auto bc(make_shared<BCKineticsLimitedDepositionMap>(nm,
898 generateVEConstant(p0),
899 generateVEConstant(limitingFactor),
900 generateVEConstant(beta),
901 map));
902 return bc;
903 }
904
905
906 SPNumMethod generateComputeSurfaceFlux(SPLBGK nm,
907 SPDataWithGhostNodesACLData fF,
908 SPAbstractDataWithGhostNodes map)
909 {
910 auto a(make_shared<ComputeSurfaceFluxMap>(nm, fF, map));
911 return a;
912 }
913
914
915 SPNumMethod generateComputeSurfaceForce(SPLBGK nm,
916 SPDataWithGhostNodesACLData fF,
917 SPAbstractDataWithGhostNodes map)
918 {
919 auto a(make_shared<ComputeSurfaceForceMap>(nm, fF, map));
920 return a;
921 }
922
923 } // asl