-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneral.cpp
More file actions
60 lines (53 loc) · 1.19 KB
/
General.cpp
File metadata and controls
60 lines (53 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "General.h"
#include "Mesh.h"
#include "Method.h"
#include "Node.h"
#include "VTKSnapshotWriter.h"
General::General()
{
mesh = 0;
method = 0;
}
General::~General()
{
if (mesh) delete mesh;
if (method) delete method;
}
int General::init()
{
finalStep = 100;
time = 0;
timeStep = 0.001;
snapStep = 1; //TODO:load parameters from file
if (mesh = new Mesh())
{if (mesh->init()) return 1;} //TODO: add filepath
else return 1;
if (method = new Method())
{if (method->init()) return 1;} //TODO: when added different methods, must be chosen from xml
else return 1;
if (sw = new VTKSnapshotWriter())
{if (sw->init()) return 1;} //TODO: when added different methods, must be chosen from xml
else return 1;
mesh->setInitialConditionsStepY(10.0,0.15);
return 0;
}
void General::setTimeStep()
{
timeStep = 1;
}
int General::step(int currentStep)
{
if (!currentStep)
sw->dump_vtk(mesh,0);
setTimeStep();
time += timeStep;
//for (int axis=0; axis<3; axis++)
for (int i=0; i<mesh->getNodesNum(); i++)
{
Node* n = mesh->getNode(i);
method->count(mesh, n, timeStep);//, axis);
}
mesh->transcend();
if (!(currentStep%snapStep))
sw->dump_vtk(mesh,currentStep+1);
}