Stiffness.h
Go to the documentation of this file.
1 /*
2 * ==========================================================================
3 * This file is part of the implementation of
4 *
5 * <FrameFab: Robotic Fabrication of Frame Shapes>
6 * Yijiang Huang, Juyong Zhang, Xin Hu, Guoxian Song, Zhongyuan Liu, Lei Yu, Ligang Liu
7 * In ACM Transactions on Graphics (Proc. SIGGRAPH Asia 2016)
8 ----------------------------------------------------------------------------
9 * class: Stiffness
10 *
11 * Description:
12 *
13 * Version: 1.0
14 * Created: Mar/23/2016
15 * Updated: Aug/24/2016
16 *
17 * Author: Xin Hu, Yijiang Huang, Guoxian Song
18 * Company: GCL@USTC
19 * Citation: Some part of this module is modified from frame3dd.c
20 * stiffness matrix construction submodule.
21 * Title: Frame3dd source code
22 * Static and dynamic structural analysis of 2D and 3D frames and trusses with
23 * elastic and geometric stiffness.
24 * Author: Henri P. Gavin
25 * Code Version: 20140514+
26 * Availability: http://frame3dd.sourceforge.net/
27 ----------------------------------------------------------------------------
28 * Copyright (C) 2016 Yijiang Huang, Xin Hu, Guoxian Song, Juyong Zhang
29 * and Ligang Liu.
30 *
31 * FrameFab is free software: you can redistribute it and/or modify
32 * it under the terms of the GNU General Public License as published by
33 * the Free Software Foundation, either version 3 of the License, or
34 * (at your option) any later version.
35 *
36 * FrameFab is distributed in the hope that it will be useful,
37 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 * GNU General Public License for more details.
40 *
41 * You should have received a copy of the GNU General Public License
42 * along with FrameFab. If not, see <http://www.gnu.org/licenses/>.
43 * ==========================================================================
44 */
45 
46 #ifndef FIBERPRINT_STIFFNESS_H
47 #define FIBERPRINT_STIFFNESS_H
48 
49 #include <iostream>
50 #include <assert.h>
51 
52 #include <Eigen/Dense>
53 #include <Eigen/Sparse>
54 #include <Eigen/SparseCore>
55 #include <Eigen/SparseCholesky>
56 #include <Eigen/SparseLU>
57 #include <Eigen/SparseQR>
58 #include <Eigen/Core>
59 #include <Eigen/OrderingMethods>
60 #include <Eigen/IterativeLinearSolvers>
61 
70 
71 using namespace std;
72 using namespace Eigen;
73 
74 class Stiffness
75 {
76 public:
77  typedef Eigen::SparseMatrix<double> SpMat;
78  typedef Eigen::MatrixXd MX;
79  typedef Eigen::VectorXd VX;
80  typedef Eigen::VectorXi VXi;
81  typedef Eigen::MatrixXi MXi;
83 
84 public:
85  Stiffness();
86  Stiffness(DualGraph *ptr_dualgraph);
87  Stiffness(
88  DualGraph *ptr_dualgraph, FiberPrintPARM *ptr_parm, char *ptr_path = NULL,
89  bool terminal_output = false, bool file_output = false
90  );
91  ~Stiffness();
92 
93 public:
94  void Init();
95  void CreateFe();
96  void CreateF(VX *ptr_x = NULL);
97  void CreateElasticK();
98  void CreateGlobalK(VX *ptr_x = NULL);
99 
100  /* calculate D using LDLT */
101  bool CalculateD(
102  VX &D,
103  VX *ptr_x = NULL,
104  bool cond_num = false,
105  int file_id = 0, string file_name = ""
106  );
107 
108  /* calculate D using ConjugateGradient by Eigen */
109  bool CalculateD(
110  VX &D,
111  VX &D0, // D0 is the last result
112  VX *ptr_x = NULL,
113  bool cond_num = false,
114  int file_id = 0, string file_name = ""
115  );
116 
117  /* Check condition number */
118  bool CheckIllCondition(IllCondDetector &stiff_inspector);
119  bool CheckError(IllCondDetector &stiff_inspector, VX &D);
120 
121  /* Write to file */
122  void WriteData(
123  VectorXd &D,
124  int id = 0,
125  string fname = "stiff_data"
126  );
127 
128  /* Data I/O */
129  SpMat *WeightedK(){ assert(&K_); return &K_; }
130  VX *WeightedF(){ assert(&F_); return &F_; }
131 
132  MX eKe(int ei); // ei: orig e id
133  MX eKv(int ei); // ei: orig e id
134  VX Fe(int ei); // ei: orig e id
135 
136  void PrintOutTimer();
137 
138 public:
141  char *ptr_path_;
142 
145 
147 
148  SpMat K_; // x-Weighted global stiffness matrix, 6n*6n
149  vector<MX> eK_; // elastic K, indexed by dual id
150  VX F_;
151  vector<VX> Fe_;
152 
153  int Ns_;
154 
155  double r_; // radius of frame
156  double nr_; // radius of node
157  double density_;
158  double g_;
159  double G_; // shear modulus
160  double E_; // young's modulus;
161  double v_; // possion ratio
162 
163  bool shear_; // 1 : shear deformation taken into consideration; 0 : not
164 
171 
174 };
175 #endif
Timer create_f_
Definition: Stiffness.h:166
double g_
Definition: Stiffness.h:158
Timer check_error_
Definition: Stiffness.h:170
Timer create_k_
Definition: Stiffness.h:168
Timer create_ek_
Definition: Stiffness.h:167
double r_
Definition: Stiffness.h:155
StiffnessSolver stiff_solver_
Definition: Stiffness.h:144
vector< VX > Fe_
Definition: Stiffness.h:151
Eigen::SparseMatrix< double > SpMat
Definition: Stiffness.h:77
trimesh::point point
Definition: Stiffness.h:82
DualGraph * ptr_dualgraph_
Definition: Stiffness.h:139
Timer check_ill_
Definition: Stiffness.h:169
double v_
Definition: Stiffness.h:161
bool shear_
Definition: Stiffness.h:163
vector< MX > eK_
Definition: Stiffness.h:149
Eigen::VectorXd VX
Definition: Stiffness.h:79
bool file_output_
Definition: Stiffness.h:173
Eigen::VectorXi VXi
Definition: Stiffness.h:80
FiberPrintPARM * ptr_parm_
Definition: Stiffness.h:140
double nr_
Definition: Stiffness.h:156
Timer create_fe_
Definition: Stiffness.h:165
double G_
Definition: Stiffness.h:159
char * ptr_path_
Definition: Stiffness.h:141
StiffnessIO stiff_io_
Definition: Stiffness.h:143
Eigen::MatrixXi MXi
Definition: Stiffness.h:81
SpMat K_
Definition: Stiffness.h:148
double E_
Definition: Stiffness.h:160
SpMat * WeightedK()
Definition: Stiffness.h:129
bool terminal_output_
Definition: Stiffness.h:172
Definition: Timer.h:48
double density_
Definition: Stiffness.h:157
CoordTrans transf_
Definition: Stiffness.h:146
Eigen::MatrixXd MX
Definition: Stiffness.h:78
VX * WeightedF()
Definition: Stiffness.h:130


choreo_task_sequence_planner
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:03:14