Debian Codegraph @

src/num/aslFDAdvectionDiffusionInhomogeneous.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 "aslFDAdvectionDiffusionInhomogeneous.h"
25 #include "aslGenerators.h"
26 #include <acl/aclGenerators.h>
27 #include "acl/acl.h"
28 #include "math/aslTemplateVE.h"
29
30 #include <data/aslDataWithGhostNodes.h>
31 #include <acl/Kernels/aclKernel.h>
32 #include <math/aslTemplates.h>
33
34 #include <acl/Kernels/aclKernelConfigurationTemplates.h>
35
36 namespace asl
37 {
38 FDAdvectionDiffusionInhomogeneous::FDAdvectionDiffusionInhomogeneous():
39 kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),
40 cData(0),
41 cInternalData(0),
42 vectorTemplate(NULL),
43 diffusivity(0)
44 {
45 }
46
47 FDAdvectionDiffusionInhomogeneous::FDAdvectionDiffusionInhomogeneous(Data c, ScalarField dC, const VectorTemplate* vT):
48 kernel(new acl::Kernel(acl::KERNEL_SIMDUA)),
49 cData(1u,c),
50 cInternalData(0u),
51 vectorTemplate(vT),
52 diffusivity(1u,dC)
53 {
54 }
55
56 void FDAdvectionDiffusionInhomogeneous::init(){
57 if (cData.size() != diffusivity.size())
58 errorMessage("FDAdvectionDiffusion::init: some of compenents are underdefined");
59
60 acl::TypeID type(getElementType(cData[0]->getDContainer()));
61
62 cInternalData.resize(cData.size());
63 for (unsigned int i(0); i < cData.size(); ++i)
64 cInternalData[i] =clone(cData[i]);
65 acl::VectorOfElements cnew(acl::generateVEPrivateVariable(1,type));
66 for (unsigned int i(0); i < cData.size(); ++i){
67 TemplateVE cT(*cData[i],d2q5());
68 TemplateVE diffusivityT(*diffusivity[i],d2q5());
69 (*kernel)<<cT.initValues;
70 (*kernel)<<diffusivityT.initValues;
71 (*kernel)<<(cnew=
72 divAgradB(diffusivityT,cT)+
73 cT.getValue(0));
74 (*kernel)<<(assignmentSafe (cInternalData[i]->getSubContainer(),cnew));
75 }
76 kernel->setup();
77 }
78
79
80 void FDAdvectionDiffusionInhomogeneous::execute()
81 {
82 kernel->compute();
83 for (unsigned int i(0); i < cData.size(); ++i)
84 swapBuffers(cData[i]->getDContainer(),cInternalData[i]->getDContainer());
85 }
86
87 void FDAdvectionDiffusionInhomogeneous::addComponent (Data c, ScalarField dC)
88 {
89 diffusivity.push_back(dC);
90 cData.push_back (c);
91 }
92 } //asl