-
Notifications
You must be signed in to change notification settings - Fork 17
/
example10.cpp
81 lines (59 loc) · 2.49 KB
/
example10.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <functional>
#include <Qt3DIncludes.h>
#include <GaussIncludes.h>
#include <ParticleSystemIncludes.h>
#include <FEMIncludes.h>
#include <tuple>
//Any extra things I need such as constraints
#include <ConstraintFixedPoint.h>
#include <TimeStepperEulerImplicitLinear.h>
#include <TimeStepperEulerImplicit.h>
#include <type_traits>
#include <UtilitiesFEM.h>
using namespace Gauss;
using namespace FEM;
using namespace ParticleSystem; //For Force Spring
/* Tetrahedral finite elements */
//typedef physical entities I need
//typedef scene
typedef PhysicalSystemFEM<double, NeohookeanTet> FEMLinearTets;
typedef World<double, std::tuple<FEMLinearTets *,PhysicalSystemParticleSingle<double> *>,
std::tuple<ForceSpringFEMParticle<double> *, ForceParticlesGravity<double> *>,
std::tuple<ConstraintFixedPoint<double> *> > MyWorld;
typedef TimeStepperEulerImplicit<double, AssemblerEigenSparseMatrix<double>,
AssemblerEigenVector<double> > MyTimeStepper;
typedef Scene<MyWorld, MyTimeStepper> MyScene;
void preStepCallback(MyWorld &world) {
// This is an example callback
}
int main(int argc, char **argv) {
std::cout<<"Test Neohookean FEM \n";
//Setup Physics
MyWorld world;
//new code -- load tetgen files
Eigen::MatrixXd V;
Eigen::MatrixXi F;
readTetgen(V, F, dataDir()+"/meshesTetgen/Beam/Beam.node", dataDir()+"/meshesTetgen/Beam/Beam.ele");
FEMLinearTets *test = new FEMLinearTets(V,F);
PhysicalSystemParticleSingle<double> *test1 = new PhysicalSystemParticleSingle<double>();
test1->getImpl().setMass(10000);
ForceSpringFEMParticle<double> *forceSpring = new ForceSpringFEMParticle<double>(PosFEM<double>(&test->getQ()[0],0, &test->getImpl().getV()),
PosParticle<double>(&test1->getQ()),
5, 2000.0);
world.addSystem(test);
world.addSystem(test1);
world.addForce(forceSpring);
fixDisplacementMin(world, test);
world.finalize(); //After this all we're ready to go (clean up the interface a bit later)
auto q = mapStateEigen(world);
q.setZero();
auto q1 = mapDOFEigen(test1->getQ(), world);
q1[0] = 5.0;
q1[1] = 7.0;
MyTimeStepper stepper(0.1);
//Display
QGuiApplication app(argc, argv);
MyScene *scene = new MyScene(&world, &stepper, preStepCallback);
GAUSSVIEW(scene);
return app.exec();
}