Debian Codegraph @

examples/massTransferSM/testSMDiff3C.cc

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 /**
25 \example testSMDiff3C.cc
26 ternary system
27 */
28
29 #include <utilities/aslParametersManager.h>
30 #include <math/aslTemplates.h>
31 #include <aslGeomInc.h>
32 #include <aslDataInc.h>
33 #include <acl/aclGenerators.h>
34 #include <writers/aslVTKFormatWriters.h>
35 #include <num/aslFDStefanMaxwell.h>
36 #include <num/aslBasicBC.h>
37 #include <utilities/aslTimer.h>
38 #include <acl/aclMath/aclVectorOfElements.h>
39
40 typedef float FlT;
41 //typedef double FlT;
42 typedef asl::UValue<double> Param;
43
44 using asl::AVec;
45 using asl::makeAVec;
46
47
48 int main(int argc, char* argv[])
49 {
50 // Optionally add appParamsManager to be able to manipulate at least
51 // hardware parameters(platform/device) through command line/parameters file
52 asl::ApplicationParametersManager appParamsManager("testSMDiff3C",
53 "1.0");
54 appParamsManager.load(argc, argv);
55
56 Param dx(1.);
57 Param dt(1.);
58 Param diffCoef(.15);
59
60 Param diffCoefNum(diffCoef.v()*dt.v()/dx.v()/dx.v());
61
62 AVec<int> size(asl::makeAVec(10,20,20));
63
64 auto gSize(dx.v()*AVec<>(size));
65
66
67 std::cout << "Flow: Data initialization... ";
68
69 asl::Block block(size,dx.v());
70
71 auto c1Field(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
72 asl::initData(c1Field, 0.33);
73 auto c2Field(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
74 asl::initData(c2Field, 0.33);
75 auto c3Field(asl::generateDataContainerACL_SP<FlT>(block, 1, 1u));
76 asl::initData(c3Field, 0.33);
77
78
79 std::cout << "Finished" << endl;
80
81 std::cout << "Flow: Numerics initialization... ";
82
83 auto templ(&asl::d3q7());
84 auto nm(generateFDStefanMaxwell(c1Field, c2Field, diffCoefNum.v(), templ));
85 nm->addComponent(c3Field,acl::generateVEConstant(asl::makeAVec(diffCoefNum.v()*.5,
86 diffCoefNum.v())));
87 nm->setDustDiffusionCoefficient(0,acl::generateVEConstant(diffCoefNum.v()*.5));
88 nm->setDustDiffusionCoefficient(1,acl::generateVEConstant(diffCoefNum.v()*.7));
89 nm->setDustDiffusionCoefficient(2,acl::generateVEConstant(diffCoefNum.v()));
90 nm->init();
91
92 std::vector<asl::SPNumMethod> bc;
93
94 bc.push_back(asl::generateBCConstantGradient(c1Field, 0, templ, {asl::Y0,asl::YE,asl::Z0,asl::ZE}));
95 bc.push_back(asl::generateBCConstantValue(c1Field, 0, {asl::X0}));
96 bc.push_back(asl::generateBCConstantValue(c1Field, 1, {asl::XE}));
97 bc.push_back(asl::generateBCConstantGradient(c2Field, 0, templ, {asl::Y0,asl::YE,asl::Z0,asl::ZE}));
98 bc.push_back(asl::generateBCConstantValue(c2Field, 0, {asl::XE}));
99 bc.push_back(asl::generateBCConstantValue(c2Field, 1, {asl::X0}));
100 bc.push_back(asl::generateBCConstantGradient(c3Field, 0, templ, {asl::X0,asl::XE,asl::Z0,asl::ZE}));
101 bc.push_back(asl::generateBCConstantValue(c3Field, 0, {asl::YE}));
102 bc.push_back(asl::generateBCConstantValue(c3Field, 1, {asl::Y0}));
103 initAll(bc);
104
105 std::cout << "Finished" << endl;
106 std::cout << "Computing..." << flush;
107 asl::Timer timer;
108
109 asl::WriterVTKXML writer(appParamsManager.getDir() + "testSMDiff3C");
110 writer.addScalars("c1", *c1Field);
111 writer.addScalars("c2", *c2Field);
112 writer.addScalars("c3", *c3Field);
113
114 executeAll(bc);
115 writer.write();
116
117 timer.start();
118 for(unsigned int i(1); i < 401; ++i)
119 {
120 nm->execute();
121 executeAll(bc);
122 if(!(i%40))
123 {
124 cout << i << endl;
125 writer.write();
126 }
127 }
128 timer.stop();
129
130 cout << "Finished" << endl;
131
132 cout << "Computation statistic:" << endl;
133 cout << "Real Time = " << timer.realTime() << "; Processor Time = "
134 << timer.processorTime() << "; Processor Load = "
135 << timer.processorLoad() * 100 << "%" << endl;
136
137 return 0;
138 }