ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
examples
massTransferSM
testSMDiff.cc
Go to the documentation of this file.
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
27
28
#include <
utilities/aslParametersManager.h
>
29
#include <
math/aslTemplates.h
>
30
#include <
aslGeomInc.h
>
31
#include <
aslDataInc.h
>
32
#include <
acl/aclGenerators.h
>
33
#include <
writers/aslVTKFormatWriters.h
>
34
#include <
num/aslFDStefanMaxwell.h
>
35
#include <
num/aslBasicBC.h
>
36
#include <
utilities/aslTimer.h
>
37
38
39
typedef
float
FlT
;
40
//typedef double FlT;
41
typedef
asl::UValue<double>
Param
;
42
43
using
asl::AVec
;
44
using
asl::makeAVec
;
45
46
47
int
main
(
int
argc,
char
* argv[])
48
{
49
// Optionally add appParamsManager to be able to manipulate at least
50
// hardware parameters(platform/device) through command line/parameters file
51
asl::ApplicationParametersManager
appParamsManager(
"testSMDiff"
,
52
"1.0"
);
53
appParamsManager.
load
(argc, argv);
54
55
Param
dx(1.);
56
Param
dt(1.);
57
Param
diffCoef(.15);
58
59
Param
diffCoefNum(diffCoef.
v
()*dt.
v
()/dx.v()/dx.v());
60
61
AVec<int>
size(
asl::makeAVec
(10, 20, 20));
62
63
auto
gSize(dx.v()*
AVec<>
(size));
64
65
66
std::cout <<
"Data initialization... "
;
67
68
asl::Block
block(size,dx.v());
69
70
auto
c1Field(
asl::generateDataContainerACL_SP<FlT>
(block, 1, 1u));
71
asl::initData
(c1Field, 0.5);
72
auto
c2Field(
asl::generateDataContainerACL_SP<FlT>
(block, 1, 1u));
73
asl::initData
(c2Field, 0.5);
74
75
76
std::cout <<
"Finished"
<< endl;
77
78
std::cout <<
"Numerics initialization... "
;
79
80
auto
templ(&
asl::d3q7
());
81
auto
nm(generateFDStefanMaxwell(c1Field, c2Field, diffCoefNum.
v
(), templ));
82
nm->setDustDiffusionCoefficient(0,
acl::generateVEConstant
(diffCoefNum.
v
()*.5));
83
nm->setDustDiffusionCoefficient(1,
acl::generateVEConstant
(diffCoefNum.
v
()));
84
nm->init();
85
86
std::vector<asl::SPNumMethod> bc;
87
88
bc.push_back(
asl::generateBCConstantGradient
(c1Field, 0, templ, {
asl::Y0
,
asl::YE
,
asl::Z0
,
asl::ZE
}));
89
bc.push_back(
asl::generateBCConstantValue
(c1Field, 0, {
asl::X0
}));
90
bc.push_back(
asl::generateBCConstantValue
(c1Field, 1, {
asl::XE
}));
91
bc.push_back(
asl::generateBCConstantGradient
(c2Field, 0, templ, {
asl::Y0
,
asl::YE
,
asl::Z0
,
asl::ZE
}));
92
bc.push_back(
asl::generateBCConstantValue
(c2Field, 0, {
asl::XE
}));
93
bc.push_back(
asl::generateBCConstantValue
(c2Field, 1, {
asl::X0
}));
94
initAll(bc);
95
96
std::cout <<
"Finished"
<< endl;
97
std::cout <<
"Computing..."
<< flush;
98
asl::Timer
timer;
99
100
asl::WriterVTKXML
writer(appParamsManager.
getDir
() +
"testSMDiff"
);
101
writer.
addScalars
(
"c1"
, *c1Field);
102
writer.
addScalars
(
"c2"
, *c2Field);
103
104
executeAll(bc);
105
writer.
write
();
106
107
timer.
start
();
108
for
(
unsigned
int
i(1); i < 401; ++i)
109
{
110
nm->execute();
111
executeAll(bc);
112
if
(!(i%40))
113
{
114
cout << i << endl;
115
writer.
write
();
116
}
117
}
118
timer.
stop
();
119
120
cout <<
"Finished"
<< endl;
121
122
cout <<
"Computation statistic:"
<< endl;
123
cout <<
"Real Time = "
<< timer.
realTime
() <<
"; Processor Time = "
124
<< timer.
processorTime
() <<
"; Processor Load = "
125
<< timer.
processorLoad
() * 100 <<
"%"
<< endl;
126
127
return
0;
128
}
aclGenerators.h
FlT
float FlT
Definition
acousticWaves.cc:40
aslBasicBC.h
aslDataInc.h
aslFDStefanMaxwell.h
aslGeomInc.h
aslParametersManager.h
aslTemplates.h
aslTimer.h
aslVTKFormatWriters.h
asl::AVec
Definition
aslVectorsDynamicLength.h:40
asl::ApplicationParametersManager
Definition
aslParametersManager.h:159
asl::ApplicationParametersManager::load
void load(int argc, char *argv[])
asl::Block
Definition
aslBlocks.h:57
asl::ParametersManager::getDir
std::string getDir()
asl::Timer
Definition
aslTimer.h:34
asl::Timer::realTime
const double realTime() const
Definition
aslTimer.h:45
asl::Timer::stop
void stop()
Definition
aslTimer.h:44
asl::Timer::processorTime
const double processorTime() const
Definition
aslTimer.h:46
asl::Timer::start
void start()
Definition
aslTimer.h:43
asl::Timer::processorLoad
const double processorLoad() const
Definition
aslTimer.h:47
asl::UValue
Updatable value. This class stores value and its TimeStamp.
Definition
aslUValue.h:35
asl::UValue::v
const T & v() const
Definition
aslUValue.h:43
asl::Writer::addScalars
void addScalars(std::string name, AbstractData &data)
asl::WriterVTKXML
Definition
aslVTKFormatWriters.h:42
asl::WriterVTKXML::write
void write()
Param
asl::UValue< FlT > Param
Definition
cubeGravity.cc:43
asl::Y0
@ Y0
Definition
aslBCond.h:309
asl::XE
@ XE
Definition
aslBCond.h:309
asl::Z0
@ Z0
Definition
aslBCond.h:309
asl::YE
@ YE
Definition
aslBCond.h:309
asl::ZE
@ ZE
Definition
aslBCond.h:309
asl::X0
@ X0
Definition
aslBCond.h:309
asl::generateDataContainerACL_SP
SPDataWrapperACLData generateDataContainerACL_SP(const Block &b, unsigned int n=1)
generates pointer to ACL Data field with n components
asl::generateBCConstantGradient
SPBCond generateBCConstantGradient(SPAbstractDataWithGhostNodes d, double v, const VectorTemplate *const t, const std::vector< SlicesNames > &sl)
Bondary condition that makes fixed gradient.
asl::generateBCConstantValue
SPBCond generateBCConstantValue(SPAbstractDataWithGhostNodes d, double v, const std::vector< SlicesNames > &sl)
Bondary condition that puts fixed value in each point.
asl::d3q7
const VectorTemplate & d3q7()
Vector template.
acl::generateVEConstant
VectorOfElements generateVEConstant(T a)
Generates VectorOfElements with 1 Element acl::Constant with value a.
asl::makeAVec
AVec< T > makeAVec(T a1)
Definition
aslVectorsDynamicLength.h:176
asl::initData
void initData(SPAbstractData d, double a)
main
int main()
Definition
testABDFormat.cc:126
Generated by
1.17.0