This repository has been archived by the owner on Nov 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
analysis2d_cloth_static.h
276 lines (233 loc) · 9.59 KB
/
analysis2d_cloth_static.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
/*
* analysis2d_cloth_static.h
* sensitive couture
*
* Created by Nobuyuki Umetani on 9/14/10.
* Copyright 2010 The University of Tokyo and Columbia University. All rights reserved.
*
*/
#if !defined(ANALYSIS_2D_CLOTH_STATIC_H)
#define ANALYSIS_2D_CLOTH_STATIC_H
#include "delfem/drawer_field.h"
#include "delfem/femls/linearsystem_field.h"
#include "delfem/ls/preconditioner.h"
#include "delfem/field_world.h"
#include "delfem/msh/surface_mesh_reader.h"
#include "delfem/drawer_cad.h"
#include "eqn_contact3d.h"
#include "cloth_handler.h"
#include "cloth_utility.h"
#include "slider_deform.h"
#include "contact_target.h"
enum SOLVER_FLAG{
SUCCESS = 0,
NOTCONV_LSSOL = 1,
NOTCONV_NR = 2,
ILU_FAIL = 3,
};
enum CLOTH_DESIGN_SYSTEM_MODE
{
CLOTH_INITIAL_LOCATION, // 0
SIMULATION_STATIC, // 1
WAITING_PICK, // 2
SENSITIVITY_DONE, // 3
SIMULATION_DETAIL, // 4
};
namespace Fem{
namespace Field{
namespace View{
class CDrawerFace;
}
}
}
class CAnalysis2D_Cloth_Static_TimeStamp{
public:
Cad::CCadObj2D cad;
Msh::CMesher2D msh;
////
Fem::Field::CFieldWorld world;
// basic
unsigned int id_field_base_;
unsigned int id_field_disp_;
unsigned int id_field_disp_buffer_;
unsigned int id_field_hinge_;
CStitchAry stitch_ary_; // stitch parameters
std::vector<CFrictionPoint> aFrictionPoint;
// detail
std::vector<CInterpBarycentric> aInterp_detail;
unsigned int id_field_base_detail_;
unsigned int id_field_disp_detail_;
unsigned int id_field_disp_buffer_detail;
unsigned int id_field_hinge_detail;
CStitchAry stitch_ary_detail;
std::vector<CFrictionPoint> aFrictionPoint_detail;
// sensitivity analysis
unsigned int id_field_lamX, id_field_lamY;
std::vector<CSolutionSensitivity> aSolSens;
////
double cur_time;
double dt;
CClothParam cloth_param; // cloth parameters
CContactParam contact_param; // contact parameters
bool is_detail;
};
//! interactive integration of shell and modeling
class CAnalysis2D_Cloth_Static
{
public:
public:
CAnalysis2D_Cloth_Static();
~CAnalysis2D_Cloth_Static(){ delete pCT; }
//// virtual
virtual void SetModelProblem(Cad::CCadObj2D& cad_2d, Msh::CMesher2D& mesh_2d, unsigned int iprob){}
virtual void Draw() const;
virtual void DrawBoundaryCondition(const Cad::CCadObj2D& cad_2d) const;
virtual void UpdateAnimationDrawer(){}
// Called from CDesigner
virtual SOLVER_FLAG UpdateMeshAndSolve(const Msh::CMesher2D& mesh_2d,
bool is_upd_coord, bool is_upd_edge,
bool is_solve_mesh_change, bool is_update_disp); //!< solve fem
void ConnectEdge(const Cad::CCadObj2D& cad, const Msh::CMesher2D& mesh_2d, unsigned int id_e1, unsigned int id_e2);
void DisconnectEdge(unsigned int id_e1,unsigned int id_e2);
// rebuild every FEM rerated things (e.g. Field LS Drawer), and solve from initial value
virtual void BuildFEM_ClearValueField( const Cad::CCadObj2D& cad_2d, const Msh::CMesher2D& mesh_2d);
virtual void BuildFEM_InterpValueField(const Cad::CCadObj2D& cad_2d, const Msh::CMesher2D& mesh_2d,
const std::vector< std::pair<unsigned int,unsigned int> >& aNewL);
void Update_Boundary_Condition_Cad_Move(Cad::CAD_ELEM_TYPE itype, unsigned int cad_elem_id,
double del_x, double del_y,
CSliderDeform& slider_deform);
virtual void Update_Boundary_Condition_Cad_Move(Cad::CAD_ELEM_TYPE itype, unsigned int cad_elem_id,
double del_x, double del_y){}
virtual void Serialize( Com::CSerializer& arch );
void MeshQualityInfo(double& max_aspect, bool& is_inverted) const;
//// non-virtual
void SetModelProblem_Cloth(Cad::CCadObj2D_Move& cad_2d, Msh::CMesher2D& mesh_2d, unsigned int iprob,
CSliderDeform& slider_deform,
std::vector< std::pair<unsigned int,unsigned int> >& aSymIdVPair);
Com::CBoundingBox3D GetBoundingBox(double rot[]) const;
void PerformStaticSolver();
void SetClothPiecePlacingMode();
CLOTH_DESIGN_SYSTEM_MODE GetMode(){ return imode_; }
void SetColor_FaceFEM(double r, double g, double b){
face_color[0] = r;
face_color[1] = g;
face_color[2] = b;
InitDrawer();
}
void MoveClothLoopInitialPosition(unsigned int id_l, double der[3]);
void SetHilight(Cad::CAD_ELEM_TYPE itype, unsigned int cad_elem_id);
void SetTextureCenter(double cent_x, double cent_y);
void SetTextureScale_FaceFEM(double scale);
bool IsSeamLine(unsigned int id_e_in, unsigned int& id_e_out, bool& is_same_dir) const;
void SetSensitivity(Cad::CAD_ELEM_TYPE itype_cad_part, unsigned int id_cad_part,
const std::vector<double>& har,
double objx, double objy);
void GuessSolutionMouseMove(double pre_x, double pre_y,
double pos_x, double pos_y);
// Time Stamp
void SaveTimeStamp(const Cad::CCadObj2D& cad_2d, const Msh::CMesher2D& mesh_2d);
void LoadTimeStamp(Cad::CCadObj2D& cad_2d, Msh::CMesher2D& mesh_2d);
bool IsBlowUp() const {
return false;
if(total_energy_ref < 0 ){ return false; }
if(total_energy_ >= total_energy_ref * 1.0e+10 ) return true;
return false;
}
//Slider
void SetSensitivity_Slider(unsigned int islider,
const std::vector<double>& har,
double val);
void GetSensitivityElem_Slider(const unsigned int no[3], const double r[3],
double sns[3], double sns2[3]) const;
void GuessSolutionSliderMove(double pre_v, double pos_v);
///////////
// Set Parameter
void SetParam_Cloth(const CClothParam& p){ this->cloth_param = p; }
void SetParam_Contact(const CContactParam& p){ this->contact_param = p; }
void SetTimeStep(double dt){ this->dt_ = dt; }
void SetIsDetail(bool is_detail,const Cad::CCadObj2D& cad_2d, const Msh::CMesher2D& mesh_2d);
void SetIsShowEdge(bool is_show);
void SetIsLighting(bool is_lighting);
void SetIsDrawPatternBoundary(bool is_draw){ this->is_draw_pattern_boundary = is_draw; }
///////////
// Get Parameter
CClothParam GetParam_Cloth() const { return this->cloth_param; }
CContactParam GetParam_Contact() const { return this->contact_param; }
double GetCurTime() const { return this->cur_time_; }
double GetStampedTime() const { return this->time_stamp.cur_time; }
double GetTimeStep() const { return this->dt_; }
bool IsDetail() const { return is_detail_; }
bool IsShowEdge() const { return is_show_edge_!= 0; }
bool IsLighting() const { return this->is_lighting_; }
bool Pick(double scrx, double scry,
const double trans0[], const double rot[], const double trans1[],
unsigned int picked_elem_nodes[3], double picked_elem_ratio[3],
unsigned int& id_l);
bool WriteObjMeshSTL(const std::string& fname,double scale){ return obj_mesh.WriteSTL(fname,scale); }
virtual SOLVER_FLAG Solve();
private:
void ClearDetailField();
void MakeDetailField(const Cad::CCadObj2D& cad_2d, const Msh::CMesher2D& mesh_2d);
virtual void ClearLinearSystemPreconditioner();
virtual void InitFieldEqn_fromMsh(const Cad::CCadObj2D& cad_2d, const Msh::CMesher2D& mesh_2d);
virtual void InitDrawer();
virtual void CreatedLoop(unsigned int id_l_created, unsigned int id_l_from){}
private:
double face_color[3];
double tex_scale;
///
double total_energy_;
double total_energy_ref;
double gx_,gy_,gz_;
unsigned int is_show_edge_;
bool is_lighting_;
bool is_draw_pattern_boundary;
unsigned int imode_sensitivity_guess_; // (0)noguess, (1)sens, (2)sens+upd, (3)gmls, (4)prg+gmls, (5)prg+mls
Cad::CAD_ELEM_TYPE itype_hilight_;
unsigned int id_hilight_;
double mouse_obj_x, mouse_obj_y;
double mouse_slider_v;
CContactTarget3D* pCT;
CClothHandler clothHandler_;
CSurfaceMeshReader obj_mesh;
// parameters
double cur_time_; // current time
double dt_;
CClothParam cloth_param; // cloth parameters
CContactParam contact_param; // contact parameters
CLOTH_DESIGN_SYSTEM_MODE imode_; // type of mode
Fem::Field::CFieldWorld world;
// sensitivity analysis
unsigned int id_field_lamX, id_field_lamY;
std::vector<CSolutionSensitivity> aSolSens;
// coarse simulation
unsigned int id_field_base; // The handle of mesh imported to FEM
unsigned int id_field_disp;
unsigned int id_field_hinge;
unsigned int id_field_disp_buffer;
CStitchAry stitch_ary_; // stitch parameters
std::vector<CFrictionPoint> aFrictionPoint;
// detail analysis
bool is_detail_;
std::vector<CInterpBarycentric> aInterp_detail;
unsigned int id_field_base_detail;
unsigned int id_field_disp_detail;
unsigned int id_field_disp_buffer_detail;
unsigned int id_field_hinge_detail;
CStitchAry stitch_ary_detail;
std::vector<CFrictionPoint> aFrictionPoint_detail;
CAnalysis2D_Cloth_Static_TimeStamp time_stamp;
////
// linear system setting
Fem::Ls::CLinearSystem_Field ls;
LsSol::CPreconditioner_ILU prec;
bool is_cleared_ls_prec;
std::vector<unsigned int> aIdECad_Fix;
std::vector<unsigned int> aIdField_Fix;
std::vector<unsigned int> aIdField_Fix_detail;
Fem::Field::View::CDrawerArrayField m_aDrawerField;
Fem::Field::View::CDrawerFace *pDF;
Fem::Field::View::CDrawerArrayField m_aDrawerField_detail;
Fem::Field::View::CDrawerFace *pDF_detail;
};
#endif