41 for(
MInt j = 0; j < nDim; j++)
42 CtrlPnt1_LagrangPnt[0][j] = 0.0;
44 for(
MInt i = 0; i < 4; i++)
45 for(
MInt j = 0; j < 3; j++)
46 CtrlPnt1_LagrangPnt[i][j] = 0.0;
47 for(
MInt i = 1; i <= nDim; i++) {
48 for(
MInt j = 0; j < nDim; j++) {
49 if(j == (i - 1)) CtrlPnt1_LagrangPnt[i][j] = geometry->m_mbminMax[j + nDim];
53 IF_CONSTEXPR(nDim == 2) CtrlPnt1_LagrangPnt[3][2] = 1.0;
60 for(
MInt i = 0; i <= 3; i++)
61 for(
MInt j = 0; j < 3; j++) {
62 CtrlPnt1_LagrangPnt[i][j] += p[j];
71 for(
MInt i = 0; i < 3; i++) {
78 mAlloc(R, 3, 3,
"R", F0, AT_);
79 if(!MATXINVT(tr, R)) {
80 for(
MInt i = 0; i < 3; i++)
81 for(
MInt j = 0; j < 3; j++)
84 for(
MInt i = 0; i < 3; i++)
85 for(
MInt j = 0; j < 3; j++)
86 trinv[i][j] = R[i][j];
87 for(
MInt i = 0; i < 4; i++) {
88 MFloat quvw[3] = {0, 0, 0}, qxyz[3] = {0, 0, 0};
89 for(
MInt j = 0; j < 3; j++)
90 quvw[j] = CtrlPnt1_LagrangPnt[i][j];
91 for(
MInt k = 0; k < 3; k++)
92 for(
MInt j = 0; j < 3; j++) {
93 qxyz[k] += trinv[k][j] * quvw[j];
95 for(
MInt j = 0; j < 3; j++)
96 CtrlPnt1_LagrangPnt[i][j] = qxyz[j];
107 for(
MInt i = 0; i < 3; i++) {
108 u[i] = CtrlPnt1_LagrangPnt[1][i] - CtrlPnt1_LagrangPnt[0][i];
109 v[i] = CtrlPnt1_LagrangPnt[2][i] - CtrlPnt1_LagrangPnt[0][i];
110 w[i] = CtrlPnt1_LagrangPnt[3][i] - CtrlPnt1_LagrangPnt[0][i];
115 for(
MInt i = 0; i < 3; i++) {
116 u[i] = u[i] / norm_u;
117 v[i] = v[i] / norm_v;
118 w[i] = w[i] / norm_w;
120 for(
MInt j = 0; j < 3; j++) {
133 MFloat quvw[3] = {0, 0, 0};
134 for(
MInt i = 0; i < 3; i++)
135 q[i] = q[i] - CtrlPnt1_LagrangPnt[0][i];
136 for(
MInt i = 0; i < 3; i++)
137 for(
MInt j = 0; j < 3; j++) {
138 quvw[i] += tr[i][j] * q[j];
140 for(
MInt i = 0; i < 3; i++)
148 IF_CONSTEXPR(nDim == 2) {
149 cerr <<
"CtrlPntToSTL is not valid for 2D." << endl;
156 mAlloc(R, 3, 3,
"R", F0, AT_);
158 if(!MATXINVT(tr, R)) {
159 for(
MInt i = 0; i < 3; i++)
160 for(
MInt j = 0; j < 3; j++)
163 for(
MInt i = 0; i < 3; i++)
164 for(
MInt j = 0; j < 3; j++)
165 trinv[i][j] = R[i][j];
167 ofstream fo(FILENAME);
168 fo <<
"solid CTRL-PNT" << endl;
170 for(
MInt e = 0; e < noElements; e++) {
171 fo << setw(15) <<
"facet normal";
172 MFloat nuvw[3] = {0, 0, 0}, nxyz[3] = {0, 0, 0};
173 for(
MInt i = 0; i < 3; i++) {
174 nuvw[i] = geometry->mbelements[e].m_normal[i];
176 for(
MInt i = 0; i < 3; i++)
177 for(
MInt j = 0; j < 3; j++) {
178 nxyz[i] += trinv[i][j] * nuvw[j];
180 for(
MInt i = 0; i < 3; i++) {
181 fo << setw(20) << nxyz[i] <<
'\t';
184 fo << setw(15) <<
"outer loop" << endl;
185 for(
MInt v = 0; v < 3; v++) {
186 MFloat quvw[3] = {0, 0, 0}, qxyz[3] = {0, 0, 0};
187 fo << setw(15) <<
"vertex";
188 for(
MInt i = 0; i < 3; i++)
189 quvw[i] = geometry->mbelements[e].m_vertices[v][i];
190 for(
MInt i = 0; i < 3; i++)
191 for(
MInt j = 0; j < 3; j++) {
192 qxyz[i] += trinv[i][j] * quvw[j];
194 for(
MInt i = 0; i < 3; i++)
195 qxyz[i] += CtrlPnt1_LagrangPnt[0][i];
196 for(
MInt i = 0; i < 3; i++) {
197 fo << setw(20) << qxyz[i];
201 fo << setw(15) <<
"endloop" << endl;
202 fo << setw(15) <<
"endfacet" << endl;
204 fo <<
"endsolid" << endl;
222 geometry->MoveAllMBElementVertex(p);
230 for(
MInt i = 0; i < 3; i++) {
236 mAlloc(R, 3, 3,
"R", F0, AT_);
238 if(!MATXINVT(tr, R)) {
239 for(
MInt i = 0; i < 3; i++)
240 for(
MInt j = 0; j < 3; j++)
243 for(
MInt i = 0; i < 3; i++)
244 for(
MInt j = 0; j < 3; j++)
245 trinv[i][j] = R[i][j];
247 for(
MInt e = 0; e < noElements; e++) {
248 for(
MInt vt = 0; vt < nDim; vt++) {
249 MFloat quvw[3] = {0, 0, 0}, qxyz[3] = {0, 0, 0};
250 for(
MInt i = 0; i < nDim; i++)
251 quvw[i] = geometry->mbelements[e].m_vertices[vt][i];
252 for(
MInt i = 0; i < 3; i++)
253 for(
MInt j = 0; j < 3; j++) {
254 qxyz[i] += trinv[i][j] * quvw[j];
256 geometry->ReplaceMBElementVertex(e, vt, qxyz);
259 CtrlPnt2_UpdateAllNormalVector();
266 for(
MInt i = 0; i < nDim; i++)
267 r[i] = geometry->mbelements[e].m_vertices[v][i];
274 geometry->MoveMBElementVertex(e, v, dx);
281 geometry->UpdateMBBoundingBox();
282 geometry->UpdateADT();
289 for(
MInt e = 0; e < noElements; e++)
290 geometry->UpdateMBNormalVector(e);
297 geometry->UpdateMBNormalVector(e);
304 for(
MInt e = 0; e < noElements; e++)
305 if(geometry->mbelements[e].m_bndCndId == bcId)
306 for(
MInt v = 0; v < nDim; v++)
307 geometry->MoveMBElementVertex(e, v, p);
315 for(
MInt i = 0; i < 3; i++) {
321 mAlloc(R, 3, 3,
"R", F0, AT_);
323 if(!MATXINVT(tr, R)) {
324 for(
MInt i = 0; i < 3; i++)
325 for(
MInt j = 0; j < 3; j++)
328 for(
MInt i = 0; i < 3; i++)
329 for(
MInt j = 0; j < 3; j++)
330 trinv[i][j] = R[i][j];
333 for(
MInt e = 0; e < noElements; e++) {
334 if(geometry->mbelements[e].m_bndCndId == bcId) {
335 for(
MInt vt = 0; vt < nDim; vt++) {
336 MFloat quvw[3] = {0, 0, 0}, qxyz[3] = {0, 0, 0};
337 for(
MInt i = 0; i < nDim; i++)
338 quvw[i] = geometry->mbelements[e].m_vertices[vt][i];
339 for(
MInt i = 0; i < 3; i++)
340 for(
MInt j = 0; j < 3; j++) {
341 qxyz[i] += trinv[i][j] * quvw[j];
343 geometry->ReplaceMBElementVertex(e, vt, qxyz);
347 CtrlPnt2_UpdateAllNormalVector();
354 if(geometry->mbelements[e].m_bndCndId == bcId) geometry->MoveMBElementVertex(e, v, dx);
362 for(
MInt e = 0; e < CtrlPnt2_getNoElements(); e++) {
363 for(
MInt v = 0; v < nDim; v++) {
365 CtrlPnt2_MoveMBElementVertex(e, v, dx, bcId);
375 IF_CONSTEXPR(nDim != 3) {
376 mTerm(1, AT_,
"Untested in 2D!");
386 rotMat[0][0] = (cos(dphi[1]) * cos(dphi[0]));
387 rotMat[0][1] = (cos(dphi[1]) * sin(dphi[0]));
388 rotMat[0][2] = (-sin(dphi[1]));
389 rotMat[1][0] = (sin(dphi[2]) * sin(dphi[1]) * cos(dphi[0]) - cos(dphi[2]) * sin(dphi[0]));
390 rotMat[1][1] = (sin(dphi[2]) * sin(dphi[1]) * sin(dphi[0]) + cos(dphi[2]) * cos(dphi[0]));
391 rotMat[1][2] = (sin(dphi[2]) * cos(dphi[1]));
392 rotMat[2][0] = (cos(dphi[2]) * sin(dphi[1]) * cos(dphi[0]) + sin(dphi[2]) * sin(dphi[0]));
393 rotMat[2][1] = (cos(dphi[2]) * sin(dphi[1]) * sin(dphi[0]) - sin(dphi[2]) * cos(dphi[0]));
394 rotMat[2][2] = (cos(dphi[2]) * cos(dphi[1]));
396 for(
MInt e = 0; e < CtrlPnt2_getNoElements(); e++) {
397 if(geometry->mbelements[e].m_bndCndId != bcId)
continue;
399 for(
MInt v = 0; v < nDim; v++) {
400 for(
MInt n = 0; n < nDim; n++) {
401 oPos[n] = geometry->mbelements[e].m_vertices[v][n];
404 nPos[0] = ori[0] + rotMat[0][0] * (oPos[0] - ori[0]) + rotMat[0][1] * (oPos[1] - ori[1])
405 + rotMat[0][2] * (oPos[2] - ori[2]);
406 nPos[1] = ori[1] + rotMat[1][0] * (oPos[0] - ori[0]) + rotMat[1][1] * (oPos[1] - ori[1])
407 + rotMat[1][2] * (oPos[2] - ori[2]);
408 nPos[2] = ori[2] + rotMat[2][0] * (oPos[0] - ori[0]) + rotMat[2][1] * (oPos[1] - ori[1])
409 + rotMat[2][2] * (oPos[2] - ori[2]);
411 for(
MInt n = 0; n < nDim; n++) {
412 dx[n] = nPos[n] - oPos[n];
416 CtrlPnt2_MoveMBElementVertex(e, v, dx, bcId);
418 geometry->UpdateMBNormalVector(e);
436 for(
MInt i = 0; i < 3; i++)
437 for(
MInt j = 0; j < 3; j++)
439 if(!LUDECMP(
a, indx, d)) {
442 for(
MInt j = 0; j < 3; j++) {
443 for(
MInt i = 0; i < 3; i++)
446 LUBKSB(
a, indx, col);
447 for(
MInt i = 0; i < 3; i++)
450 for(
MInt i = 0; i < 3; i++)
451 for(
MInt j = 0; j < 3; j++)
463 const MFloat TINY = 1.0e-20;
464 MInt imax = std::numeric_limits<MInt>::min();
466 static const MInt n = 3;
469 for(
MInt i = 0; i < n; i++) {
471 for(
MInt j = 0; j < n; j++) {
473 if(temp > big) big = temp;
475 if(
approx(big, 0.0, MFloatEps)) {
480 for(
MInt j = 0; j < n; j++) {
481 for(
MInt i = 0; i < j; i++) {
483 for(
MInt k = 0; k < i; k++)
484 sum -=
a[i][k] *
a[k][j];
488 for(
MInt i = j; i < n; i++) {
490 for(
MInt k = 0; k < j; k++)
491 sum -=
a[i][k] *
a[k][j];
493 MFloat dum = vv[i] * fabs(sum);
500 for(
MInt k = 0; k < n; k++) {
502 a[imax][k] =
a[j][k];
509 if(
approx(
a[j][j], 0.0, MFloatEps))
a[j][j] = TINY;
512 for(
MInt i = j + 1; i < n; i++)
524 MInt i, ii = 0, ip, j;
527 for(i = 0; i < n; i++) {
532 for(j = ii - 1; j < i; j++)
533 sum -=
a[i][j] *
b[j];
534 else if(!
approx(sum, 0.0, MFloatEps))
538 for(i = n - 1; i >= 0; i--) {
540 for(j = i + 1; j < n; j++)
541 sum -=
a[i][j] *
b[j];
542 b[i] = sum /
a[i][i];
550 IF_CONSTEXPR(nDim == 2) {
551 MFloat middle[3] = {0.0, 0.0, 0.0};
552 ofstream fo(FILENAME);
555 for(
MInt i = 0; i < 2; i++) {
558 for(
MInt e = 0; e < noElements; e++) {
559 if(geometry->mbelements[e].m_bndCndId == bcId) {
561 for(
MInt v = 0; v < 2; v++) {
562 for(
MInt i = 0; i < 2; i++) {
563 middle[i] += geometry->mbelements[e].m_vertices[0][i];
568 for(
MInt i = 0; i < 2; i++) {
569 middle[i] = middle[i] / (noElem * 2);
572 fo <<
"solid CTRL-PNT" << endl;
574 for(
MInt e = 0; e < noElements; e++) {
575 if(geometry->mbelements[e].m_bndCndId == bcId) {
576 fo << setw(15) <<
"facet normal";
577 for(
MInt i = 0; i < 2; i++) {
578 fo << setw(20) << 0.0;
580 fo << setw(20) << 1.0;
582 fo << setw(15) <<
"outer loop" << endl;
583 for(
MInt v = 0; v < 2; v++) {
584 fo << setw(15) <<
"vertex";
585 for(
MInt i = 0; i < 2; i++) {
586 fo << setw(20) << geometry->mbelements[e].m_vertices[v][i];
588 fo << setw(20) << F0;
591 fo << setw(15) <<
"vertex";
592 for(
MInt i = 0; i < 3; i++) {
593 fo << setw(20) << middle[i];
596 fo << setw(15) <<
"endloop" << endl;
597 fo << setw(15) <<
"endfacet" << endl;
600 fo <<
"endsolid" << endl;
604 ofstream fo(FILENAME);
605 fo <<
"solid CTRL-PNT" << endl;
607 for(
MInt e = 0; e < noElements; e++) {
608 if(geometry->mbelements[e].m_bndCndId == bcId) {
609 fo << setw(15) <<
"facet normal";
610 for(
MInt i = 0; i < 3; i++) {
611 fo << setw(20) << geometry->mbelements[e].m_normal[i];
614 fo << setw(15) <<
"outer loop" << endl;
615 for(
MInt v = 0; v < 3; v++) {
616 fo << setw(15) <<
"vertex";
617 for(
MInt i = 0; i < 3; i++) {
618 fo << setw(20) << geometry->mbelements[e].m_vertices[v][i];
622 fo << setw(15) <<
"endloop" << endl;
623 fo << setw(15) <<
"endfacet" << endl;
626 fo <<
"endsolid" << endl;
635 ofstream fo(FILENAME);
636 for(
MInt e = 0; e < noElements; e++) {
637 for(
MInt v = 0; v < nDim; v++) {
638 for(
MInt i = 0; i < nDim; i++) {
639 fo << geometry->mbelements[e].m_vertices[v][i] <<
'\t';
649 return sqrt(pow(r[0], 2) + pow(r[1], 2) + pow(r[2], 2));
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
MBool mDeallocate(T *&a)
deallocates the memory previously allocated for element 'a'
Collector< element< nDim > > * m_mbelements
void CtrlPnt2_Initialize(Geometry< nDim > *g, MInt dimensions)
void CtrlPnt2_UpdateNormalVector(MInt e)
void CtrlPnt1_CtrlPntToSTL(const MChar *FILNAME)
void LUBKSB(MFloat **a, MInt *indx, MFloat *b)
void CtrlPnt2_InitOrientation(MFloat *u, MFloat *v, MFloat *w)
void CtrlPnt2_CtrlPntToSTL(const MChar *FILENAME, MInt bcId)
void CtrlPnt2_getMBElementVertex(MInt e, MInt v, MFloat *r)
void CtrlPnt2_CtrlPntToGNUPlot(const MChar *FILENAME)
void CtrlPnt1_InitOrientation(MFloat *u, MFloat *v, MFloat *w)
void CtrlPnt1_quvw(MFloat *q)
void CtrlPnt1_InitPosition(MFloat *p)
void CtrlPnt2_shiftSTL(MInt bcId, MFloat *dx)
void CtrlPnt2_rotateSTL(MInt bcId, MFloat *dphi, MFloat *ori)
void CtrlPnt2_UpdateAllNormalVector()
void CtrlPnt2_InitPosition(MFloat *p)
void CtrlPnt2_MoveMBElementVertex(MInt e, MInt v, MFloat *dx)
MBool LUDECMP(MFloat **a, MInt *indx, MFloat &d)
MBool MATXINVT(MFloat T[3][3], MFloat **R)
void CtrlPnt1_Initialize(Geometry< nDim > *g, MInt dimensions)
void mTerm(const MInt errorCode, const MString &location, const MString &message)
MBool approx(const T &, const U &, const T)