TexGen
ShearedPeriodicBoundaries.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2010 Louise Brown
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18=============================================================================*/
19
20#include "PrecompiledHeaders.h"
21#include "TexGen.h"
23
24
25using namespace TexGen;
26using namespace std;
27
28CShearedPeriodicBoundaries::CShearedPeriodicBoundaries(void)
29{
30}
31
33{
34}
35
37{
38 double Angle1, Angle2;
39 XYZ StartPoint = Mesh.GetNode(0);
40 XYZ Node4 = Mesh.GetNode(4);
41 XYZ Node2 = Mesh.GetNode(2);
42
43 m_DomSize.x = GetLength( StartPoint, Node4 );
44 m_DomSize.y = GetLength( StartPoint, Node2 );
45 m_DomSize.z = GetLength( StartPoint, Mesh.GetNode(1) );
46 Angle1 = atan2( Node4.y - StartPoint.y, Node4.x - StartPoint.x );
47 Angle2 = atan2( Node2.y - StartPoint.y, Node2.x - StartPoint.x );
48
49 m_Domyx = m_DomSize.y * cos(Angle2);
50 m_Domyy = m_DomSize.y * sin(Angle2);
51}
52
53void CShearedPeriodicBoundaries::OutputEquations( ostream& Output, int iBoundaryConditions )
54{
55 Output << "***************************" << endl;
56 Output << "*** BOUNDARY CONDITIONS ***" << endl;
57 Output << "***************************" << endl;
58
59 Output << "*** Name: Translation stop Vertex 1 Type: Displacement/Rotation" << endl;
60 Output << "*Boundary" << endl;
61 Output << "MasterNode1, 1, 1" << endl;
62 Output << "MasterNode1, 2, 2" << endl;
63 Output << "MasterNode1, 3, 3" << endl;
64 Output << endl;
65
66 Output << "*****************" << endl;
67 Output << "*** EQUATIONS ***" << endl;
68 Output << "*****************" << endl;
69 Output << "*parameter" << endl;
70 Output << "***unit cell X dimension" << endl;
71 Output << "x=" << m_DomSize.x << endl;
72 Output << "***Unit cel sheared Y dimension " << endl;
73 Output << "yx=" << m_Domyx << endl;
74 Output << "yy=" << m_Domyy << endl;
75 Output << "***unit cell Z dimension" << endl;
76 Output << "z=" << m_DomSize.z << endl;
77 Output << "*Equation" << endl;
78 Output << "3" << endl;
79 Output << "FaceA, 1, 1.0, FaceB, 1, -1.0, ConstraintsDriver0, 1, -<x>" << endl;
80 Output << "*Equation" << endl;
81 Output << "2" << endl;
82 Output << "FaceA, 2, 1.0, FaceB, 2, -1.0" << endl;
83 Output << "*Equation" << endl;
84 Output << "2" << endl;
85 Output << "FaceA, 3, 1.0, FaceB, 3, -1.0" << endl;
86 Output << "*Equation" << endl;
87 Output << "4" << endl;
88 Output << "FaceC, 1, 1.0, FaceD, 1, -1.0, ConstraintsDriver3, 1, -<yy>," << endl;
89 Output << "ConstraintsDriver0, 1, -<yx>" << endl;
90 Output << "*Equation" << endl;
91 Output << "3" << endl;
92 Output << "FaceC, 2, 1.0, FaceD, 2, -1.0, ConstraintsDriver1, 1, -<yy>" << endl;
93 Output << "*Equation" << endl;
94 Output << "2" << endl;
95 Output << "FaceC, 3, 1.0, FaceD, 3, -1.0" << endl;
96 Output << "*Equation" << endl;
97 Output << "3" << endl;
98 Output << "FaceE, 1, 1.0, FaceF, 1, -1.0, ConstraintsDriver4, 1, -<z>" << endl;
99 Output << "*Equation" << endl;
100 Output << "3" << endl;
101 Output << "FaceE, 2, 1.0, FaceF, 2, -1.0, ConstraintsDriver5, 1, -<z>" << endl;
102 Output << "*Equation" << endl;
103 Output << "3" << endl;
104 Output << "FaceE, 3, 1.0, FaceF, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
105 Output << "************************************************" << endl;
106 Output << "*Equation" << endl;
107 Output << "3" << endl;
108 Output << "Edge2, 1, 1.0, Edge1, 1, -1.0, ConstraintsDriver0, 1, -<x>" << endl;
109 Output << "*Equation" << endl;
110 Output << "2" << endl;
111 Output << "Edge2, 2, 1.0, Edge1, 2, -1.0" << endl;
112 Output << "*Equation" << endl;
113 Output << "2" << endl;
114 Output << "Edge2, 3, 1.0, Edge1, 3, -1.0" << endl;
115 Output << "*Equation" << endl;
116 Output << "5" << endl;
117 Output << "Edge3, 1, 1.0, Edge1, 1, -1.0, ConstraintsDriver0, 1, -<x>, " << endl;
118 Output << "ConstraintsDriver3, 1, -<yy>, ConstraintsDriver0, 1, -<yx>" << endl;
119 Output << "*Equation" << endl;
120 Output << "3" << endl;
121 Output << "Edge3, 2, 1.0, Edge1, 2, -1.0, ConstraintsDriver1, 1, -<yy>" << endl;
122 Output << "*Equation" << endl;
123 Output << "2" << endl;
124 Output << "Edge3, 3, 1.0, Edge1, 3, -1.0" << endl;
125 Output << "*Equation" << endl;
126 Output << "4" << endl;
127 Output << "Edge4, 1, 1.0, Edge1, 1, -1.0," << endl;
128 Output << "ConstraintsDriver3, 1, -<yy>, ConstraintsDriver0, 1, -<yx>" << endl;
129 Output << "*Equation" << endl;
130 Output << "3" << endl;
131 Output << "Edge4, 2, 1.0, Edge1, 2, -1.0, ConstraintsDriver1, 1, -<yy>" << endl;
132 Output << "*Equation" << endl;
133 Output << "2" << endl;
134 Output << "Edge4, 3, 1.0, Edge1, 3, -1.0" << endl;
135 Output << "*Equation" << endl;
136 Output << "3" << endl;
137 Output << "Edge6, 1, 1.0, Edge5, 1, -1.0, ConstraintsDriver0, 1, -<x>" << endl;
138 Output << "*Equation" << endl;
139 Output << "2" << endl;
140 Output << "Edge6, 2, 1.0, Edge5, 2, -1.0" << endl;
141 Output << "*Equation" << endl;
142 Output << "2" << endl;
143 Output << "Edge6, 3, 1.0, Edge5, 3, -1.0" << endl;
144 Output << "*Equation" << endl;
145 Output << "4" << endl;
146 Output << "Edge7, 1, 1.0, Edge5, 1, -1.0, ConstraintsDriver0, 1, -<x>," << endl;
147 Output << "ConstraintsDriver4, 1, -<z>" << endl;
148 Output << "*Equation" << endl;
149 Output << "3" << endl;
150 Output << "Edge7, 2, 1.0, Edge5, 2, -1.0, ConstraintsDriver5, 1, -<z>" << endl;
151 Output << "*Equation" << endl;
152 Output << "3" << endl;
153 Output << "Edge7, 3, 1.0, Edge5, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
154 Output << "*Equation" << endl;
155 Output << "3" << endl;
156 Output << "Edge8, 1, 1.0, Edge5, 1, -1.0, ConstraintsDriver4, 1, -<z>" << endl;
157 Output << "*Equation" << endl;
158 Output << "3" << endl;
159 Output << "Edge8, 2, 1.0, Edge5, 2, -1.0, ConstraintsDriver5, 1, -<z>" << endl;
160 Output << "*Equation" << endl;
161 Output << "3" << endl;
162 Output << "Edge8, 3, 1.0, Edge5, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
163 Output << "*Equation" << endl;
164 Output << "4" << endl;
165 Output << "Edge10, 1, 1.0, Edge9, 1, -1.0, " << endl;
166 Output << "ConstraintsDriver3, 1, -<yy>, ConstraintsDriver0, 1, -<yx>" << endl;
167 Output << "*Equation" << endl;
168 Output << "3" << endl;
169 Output << "Edge10, 2, 1.0, Edge9, 2, -1.0, ConstraintsDriver1, 1, -<yy>" << endl;
170 Output << "*Equation" << endl;
171 Output << "2" << endl;
172 Output << "Edge10, 3, 1.0, Edge9, 3, -1.0" << endl;
173 Output << "*Equation" << endl;
174 Output << "5" << endl;
175 Output << "Edge11, 1, 1.0, Edge9, 1, -1.0,ConstraintsDriver3, 1, -<yy>," << endl;
176 Output << "ConstraintsDriver0, 1, -<yx>,ConstraintsDriver4, 1, -<z>" << endl;
177 Output << "*Equation" << endl;
178 Output << "4" << endl;
179 Output << "Edge11, 2, 1.0, Edge9, 2, -1.0, ConstraintsDriver1, 1, -<yy>," << endl;
180 Output << "ConstraintsDriver5, 1, -<z>" << endl;
181 Output << "*Equation" << endl;
182 Output << "3" << endl;
183 Output << "Edge11, 3, 1.0, Edge9, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
184 Output << "*Equation" << endl;
185 Output << "3" << endl;
186 Output << "Edge12, 1, 1.0, Edge9, 1, -1.0, ConstraintsDriver4, 1, -<z>" << endl;
187 Output << "*Equation" << endl;
188 Output << "3" << endl;
189 Output << "Edge12, 2, 1.0, Edge9, 2, -1.0, ConstraintsDriver5, 1, -<z>" << endl;
190 Output << "*Equation" << endl;
191 Output << "3" << endl;
192 Output << "Edge12, 3, 1.0, Edge9, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
193 Output << "******************************************************" << endl;
194 Output << "*Equation" << endl;
195 Output << "3" << endl;
196 Output << "MasterNode2, 1, 1.0, MasterNode1, 1, -1.0, ConstraintsDriver0, 1, -<x>" << endl;
197 Output << "*Equation" << endl;
198 Output << "2" << endl;
199 Output << "MasterNode2, 2, 1.0, MasterNode1, 2, -1.0" << endl;
200 Output << "*Equation" << endl;
201 Output << "2" << endl;
202 Output << "MasterNode2, 3, 1.0, MasterNode1, 3, -1.0" << endl;
203 Output << "*Equation" << endl;
204 Output << "5" << endl;
205 Output << "MasterNode3, 1, 1.0, MasterNode1, 1, -1.0, ConstraintsDriver0, 1, -<x>, " << endl;
206 Output << "ConstraintsDriver3, 1, -<yy>, ConstraintsDriver0, 1, -<yx>" << endl;
207 Output << "*Equation" << endl;
208 Output << "3" << endl;
209 Output << "MasterNode3, 2, 1.0, MasterNode1, 2, -1.0, ConstraintsDriver1, 1, -<yy>" << endl;
210 Output << "*Equation" << endl;
211 Output << "2" << endl;
212 Output << "MasterNode3, 3, 1.0, MasterNode1, 3, -1.0" << endl;
213 Output << "*Equation" << endl;
214 Output << "4" << endl;
215 Output << "MasterNode4, 1, 1.0, MasterNode1, 1, -1.0," << endl;
216 Output << "ConstraintsDriver3, 1, -<yy>, ConstraintsDriver0, 1, -<yx>" << endl;
217 Output << "*Equation" << endl;
218 Output << "3" << endl;
219 Output << "MasterNode4, 2, 1.0, MasterNode1, 2, -1.0, ConstraintsDriver1, 1, -<yy>" << endl;
220 Output << "*Equation" << endl;
221 Output << "2" << endl;
222 Output << "MasterNode4, 3, 1.0, MasterNode1, 3, -1.0" << endl;
223 Output << "*Equation" << endl;
224 Output << "3" << endl;
225 Output << "MasterNode5, 1, 1.0, MasterNode1, 1, -1.0, ConstraintsDriver4, 1, -<z>" << endl;
226 Output << "*Equation" << endl;
227 Output << "3" << endl;
228 Output << "MasterNode5, 2, 1.0, MasterNode1, 2, -1.0, ConstraintsDriver5, 1, -<z>" << endl;
229 Output << "*Equation" << endl;
230 Output << "3" << endl;
231 Output << "MasterNode5, 3, 1.0, MasterNode1, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
232 Output << "*Equation" << endl;
233 Output << "4" << endl;
234 Output << "MasterNode6, 1, 1.0, MasterNode1, 1, -1.0, ConstraintsDriver0, 1, -<x>, " << endl;
235 Output << "ConstraintsDriver4, 1, -<z>" << endl;
236 Output << "*Equation" << endl;
237 Output << "3" << endl;
238 Output << "MasterNode6, 2, 1.0, MasterNode1, 2, -1.0, ConstraintsDriver5, 1, -<z>" << endl;
239 Output << "*Equation" << endl;
240 Output << "3" << endl;
241 Output << "MasterNode6, 3, 1.0, MasterNode1, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
242 Output << "*Equation" << endl;
243 Output << "6" << endl;
244 Output << "MasterNode7, 1, 1.0, MasterNode1, 1, -1.0, ConstraintsDriver0, 1, -<x>," << endl;
245 Output << "ConstraintsDriver3, 1, -<yy>, ConstraintsDriver0, 1, -<yx>," << endl;
246 Output << "ConstraintsDriver4, 1, -<z>" << endl;
247 Output << "*Equation" << endl;
248 Output << "4" << endl;
249 Output << "MasterNode7, 2, 1.0, MasterNode1, 2, -1.0, ConstraintsDriver1, 1, -<yy>, " << endl;
250 Output << "ConstraintsDriver5, 1, -<z>" << endl;
251 Output << "*Equation" << endl;
252 Output << "3" << endl;
253 Output << "MasterNode7, 3, 1.0, MasterNode1, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
254 Output << "*Equation" << endl;
255 Output << "5" << endl;
256 Output << "MasterNode8, 1, 1.0, MasterNode1, 1, -1.0, ConstraintsDriver3, 1, -<yy>," << endl;
257 Output << "ConstraintsDriver0, 1, -<yx>, ConstraintsDriver4, 1, -<z>" << endl;
258 Output << "*Equation" << endl;
259 Output << "4" << endl;
260 Output << "MasterNode8, 2, 1.0, MasterNode1, 2, -1.0, ConstraintsDriver1, 1, -<yy>, " << endl;
261 Output << "ConstraintsDriver5, 1, -<z>" << endl;
262 Output << "*Equation" << endl;
263 Output << "3" << endl;
264 Output << "MasterNode8, 3, 1.0, MasterNode1, 3, -1.0, ConstraintsDriver2, 1, -<z>" << endl;
265
266}
Defines the nodes and elements of a surface or volume mesh.
Definition: Mesh.h:58
const XYZ & GetNode(int iIndex) const
Get the node with given ID.
Definition: Mesh.cpp:2636
void SetDomainSize(const CMesh &Mesh)
Set up the domain size parameters used in the equations.
void OutputEquations(ostream &Output, int iBoundaryConditions)
Output equations for sheared domain boundary conditions.
Namespace containing a series of customised math operations not found in the standard c++ library.
double GetLength(const XYZ &Point1, const XYZ &Point2)
Get the length between two points.
Definition: mymath.h:540
Struct for representing points in 3D space.
Definition: mymath.h:56
double z
Definition: mymath.h:57
double x
Definition: mymath.h:57
double y
Definition: mymath.h:57