proteus  1.8.1
C/C++/Fortran libraries
createAnalyticGeometry.cpp
Go to the documentation of this file.
2 #include "MeshAdaptPUMI.h"
3 #include <ma.h>
4 #include <lionPrint.h>
5 
6 //routines to create analytic sphere in a 3D box
7 
8 agm_bdry add_bdry(gmi_model* m, gmi_ent* e)
9 {
10  return agm_add_bdry(gmi_analytic_topo(m), agm_from_gmi(e));
11 }
12 
13 agm_use add_adj(gmi_model* m, agm_bdry b, int tag)
14 {
15  agm* topo = gmi_analytic_topo(m);
16  int dim = agm_dim_from_type(agm_bounds(topo, b).type);
17  gmi_ent* de = gmi_find(m, dim - 1, tag);
18  return agm_add_use(topo, b, agm_from_gmi(de));
19 }
20 
21 double boxLength;
22 double boxWidth;
23 double boxHeight;
24 int edgeMap[12] = {50,48,46,52,11,16,20,6,73,72,71,74};
25 int faceLoop[6] = {80,78,76,82,42,24};
26 
27 
28 void vert0(double const p[2], double x[3], void*)
29 {
30  (void)p;
31  x[0] = 0.0;
32  x[1] = 0.0;
33  x[2] = 0.0;
34 
35 }
36 void vert1(double const p[2], double x[3], void*)
37 {
38  (void)p;
39  x[0] = boxLength;
40  x[1] = 0.0;
41  x[2] = 0.0;
42 }
43 
44 void vert2(double const p[2], double x[3], void*)
45 {
46  (void)p;
47  x[0] = boxLength;
48  x[1] = boxWidth;
49  x[2] = 0.0;
50 }
51 
52 void vert3(double const p[2], double x[3], void*)
53 {
54  (void)p;
55  x[0] = 0.0;
56  x[1] = boxWidth;
57  x[2] = 0.0;
58 }
59 
60 void vert4(double const p[2], double x[3], void*)
61 {
62  (void)p;
63  x[0] = 0.0;
64  x[1] = 0.0;
65  x[2] = boxHeight;
66 
67 }
68 void vert5(double const p[2], double x[3], void*)
69 {
70  (void)p;
71  x[0] = boxLength;
72  x[1] = 0.0;
73  x[2] = boxHeight;
74 }
75 
76 void vert6(double const p[2], double x[3], void*)
77 {
78  (void)p;
79  x[0] = boxLength;
80  x[1] = boxWidth;
81  x[2] = boxHeight;
82 }
83 
84 void vert7(double const p[2], double x[3], void*)
85 {
86  (void)p;
87  x[0] = 0.0;
88  x[1] = boxWidth;
89  x[2] = boxHeight;
90 }
91 
92 void edge0(double const p[2], double x[3], void*)
93 {
94  x[0] = boxLength*p[0];
95  x[1] = 0.0;
96  x[2] = 0.0;
97 }
98 
99 void edge1(double const p[2], double x[3], void*)
100 {
101  x[0] = boxLength;
102  x[1] = boxWidth*p[0];
103  x[2] = 0.0;
104 }
105 
106 void edge2(double const p[2], double x[3], void*)
107 {
108  x[0] = boxLength*p[0];
109  x[1] = boxWidth;
110  x[2] = 0.0;
111 }
112 
113 void edge3(double const p[2], double x[3], void*)
114 {
115  x[0] = 0.0;
116  x[1] = boxWidth*p[0];
117  x[2] = 0.0;
118 }
119 
120 void edge4(double const p[2], double x[3], void*)
121 {
122  x[0] = boxLength*p[0];
123  x[1] = 0.0;
124  x[2] = boxHeight;
125 }
126 
127 void edge5(double const p[2], double x[3], void*)
128 {
129  x[0] = boxLength;
130  x[1] = boxWidth*p[0];
131  x[2] = boxHeight;
132 }
133 
134 void edge6(double const p[2], double x[3], void*)
135 {
136  x[0] = boxLength*p[0];
137  x[1] = boxWidth;
138  x[2] = boxHeight;
139 }
140 
141 void edge7(double const p[2], double x[3], void*)
142 {
143  x[0] = 0.0;
144  x[1] = boxWidth*p[0];
145  x[2] = boxHeight;
146 }
147 
148 void edge8(double const p[2], double x[3], void*)
149 {
150  x[0] = 0.0;
151  x[1] = 0.0;
152  x[2] = boxHeight*p[0];
153 }
154 
155 void edge9(double const p[2], double x[3], void*)
156 {
157  x[0] = boxLength;
158  x[1] = 0.0;
159  x[2] = boxHeight*p[0];
160 }
161 
162 void edge10(double const p[2], double x[3], void*)
163 {
164  x[0] = boxLength;
165  x[1] = boxWidth;
166  x[2] = boxHeight*p[0];
167 }
168 
169 void edge11(double const p[2], double x[3], void*)
170 {
171  x[0] = 0.0;
172  x[1] = boxWidth;
173  x[2] = boxHeight*p[0];
174 }
175 
176 void face0(double const p[2], double x[3], void*)
177 {
178  x[0] = boxLength*p[0];
179  x[1] = 0.0;
180  x[2] = boxHeight*p[1];
181 }
182 
183 void face1(double const p[2], double x[3], void*)
184 {
185  x[0] = boxLength;
186  x[1] = boxWidth*p[0];
187  x[2] = boxHeight*p[1];
188 }
189 
190 void face2(double const p[2], double x[3], void*)
191 {
192  x[0] = boxLength*p[0];
193  x[1] = boxWidth;
194  x[2] = boxHeight*p[1];
195 }
196 
197 void face3(double const p[2], double x[3], void*)
198 {
199  x[0] = 0.0;
200  x[1] = boxWidth*p[0];
201  x[2] = boxHeight*p[1];
202 }
203 void face4(double const p[2], double x[3], void*)
204 {
205  x[0] = boxLength*p[0];
206  x[1] = boxWidth*p[1];
207  x[2] = 0.0;
208 }
209 void face5(double const p[2], double x[3], void*)
210 {
211  x[0] = boxLength*p[0];
212  x[1] = boxWidth*p[1];
213  x[2] = boxHeight;
214 }
215 
216 void reparamVert_zero(double const from[2], double to[2], void*)
217 {
218  (void)from;
219  to[0] = 0;
220  to[1] = 0;
221 }
222 void reparamVert_one(double const from[2], double to[2], void*)
223 {
224  (void)from;
225  to[0] = 1;
226  to[1] = 0;
227 }
228 
229 //from edge parameterization to face parameterization
230 void reparamEdge_0(double const from[2], double to[2], void*)
231 {
232  to[0] = from[0];
233  to[1] = 0.0;
234 }
235 
236 void reparamEdge_1(double const from[2], double to[2], void*)
237 {
238  to[0] = 0.0;
239  to[1] = from[0];
240 }
241 void reparamEdge_2(double const from[2], double to[2], void*)
242 {
243  to[0] = from[0];
244  to[1] = 1.0;
245 }
246 
247 void reparamEdge_3(double const from[2], double to[2], void*)
248 {
249  to[0] = 1.0;
250  to[1] = from[0];
251 }
252 
253 
254 
255 
256 
257 void regionFunction(double const p[2], double x[3], void*)
258 {
259  (void)p;
260  (void)x;
261 }
262 
263 
264 void makeBox(gmi_model* model)
265 {
266  //making a box
267 
268  int vertPer = 0;
269  double vertRan[1][2] = {{0.0,0.0}};
270  int vertexMap[8] = {58,56,54,60,5,10,15,2};
271  gmi_ent* g_vert[8];
272  g_vert[0] = gmi_add_analytic(model, 0, 58, vert0, &vertPer, vertRan, 0);
273  g_vert[1] = gmi_add_analytic(model, 0, 56, vert1, &vertPer, vertRan, 0);
274  g_vert[2] = gmi_add_analytic(model, 0, 54, vert2, &vertPer, vertRan, 0);
275  g_vert[3] = gmi_add_analytic(model, 0, 60, vert3, &vertPer, vertRan, 0);
276  g_vert[4] = gmi_add_analytic(model, 0, 5, vert4, &vertPer, vertRan, 0);
277  g_vert[5] = gmi_add_analytic(model, 0, 10, vert5, &vertPer, vertRan, 0);
278  g_vert[6] = gmi_add_analytic(model, 0, 15, vert6, &vertPer, vertRan, 0);
279  g_vert[7] = gmi_add_analytic(model, 0, 2, vert7, &vertPer, vertRan, 0);
280 
281 
282  int edgePer = 0;
283  double edgeRan[1][2] = {{0.0,1.0}};
284  gmi_ent* g_edge[12];
285 
286  g_edge[0] = gmi_add_analytic(model, 1, 50, edge0, &edgePer, edgeRan, 0);
287  g_edge[1] = gmi_add_analytic(model, 1, 48, edge1, &edgePer, edgeRan, 0);
288  g_edge[2] = gmi_add_analytic(model, 1, 46, edge2, &edgePer, edgeRan, 0);
289  g_edge[3] = gmi_add_analytic(model, 1, 52, edge3, &edgePer, edgeRan, 0);
290  g_edge[4] = gmi_add_analytic(model, 1, 11, edge4, &edgePer, edgeRan, 0);
291  g_edge[5] = gmi_add_analytic(model, 1, 16, edge5, &edgePer, edgeRan, 0);
292  g_edge[6] = gmi_add_analytic(model, 1, 20, edge6, &edgePer, edgeRan, 0);
293  g_edge[7] = gmi_add_analytic(model, 1, 6, edge7, &edgePer, edgeRan, 0);
294  g_edge[8] = gmi_add_analytic(model, 1, 73, edge8, &edgePer, edgeRan, 0);
295  g_edge[9] = gmi_add_analytic(model, 1, 72, edge9, &edgePer, edgeRan, 0);
296  g_edge[10] = gmi_add_analytic(model, 1, 71, edge10, &edgePer, edgeRan, 0);
297  g_edge[11] = gmi_add_analytic(model, 1, 74, edge11, &edgePer, edgeRan, 0);
298 
299  //reparameterize vertices on edges
300  agm_bdry b;
301  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[0]));
302  agm_use edgeUse0 = add_adj(model, b, vertexMap[0]);
303  agm_use edgeUse0_1 = add_adj(model,b,vertexMap[1]);
304  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
305  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
306 
307  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[1]));
308  edgeUse0 = add_adj(model, b, vertexMap[1]);
309  edgeUse0_1 = add_adj(model,b,vertexMap[2]);
310  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
311  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
312 
313  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[2]));
314  edgeUse0 = add_adj(model, b, vertexMap[2]);
315  edgeUse0_1 = add_adj(model,b,vertexMap[3]);
316  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_one, 0);
317  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_zero, 0);
318 
319  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[3]));
320  edgeUse0 = add_adj(model, b, vertexMap[3]);
321  edgeUse0_1 = add_adj(model,b,vertexMap[0]);
322  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_one, 0);
323  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_zero, 0);
324 
325  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[4]));
326  edgeUse0 = add_adj(model, b, vertexMap[4]);
327  edgeUse0_1 = add_adj(model,b,vertexMap[5]);
328  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
329  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
330 
331  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[5]));
332  edgeUse0 = add_adj(model, b, vertexMap[5]);
333  edgeUse0_1 = add_adj(model,b,vertexMap[6]);
334  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
335  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
336 
337  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[6]));
338  edgeUse0 = add_adj(model, b, vertexMap[6]);
339  edgeUse0_1 = add_adj(model,b,vertexMap[7]);
340  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_one, 0);
341  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_zero, 0);
342 
343  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[7]));
344  edgeUse0 = add_adj(model, b, vertexMap[7]);
345  edgeUse0_1 = add_adj(model,b,vertexMap[4]);
346  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_one, 0);
347  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_zero, 0);
348 
349  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[8]));
350  edgeUse0 = add_adj(model, b, vertexMap[0]);
351  edgeUse0_1 = add_adj(model,b,vertexMap[4]);
352  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
353  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
354 
355  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[9]));
356  edgeUse0 = add_adj(model, b, vertexMap[1]);
357  edgeUse0_1 = add_adj(model,b,vertexMap[5]);
358  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
359  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
360 
361  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[10]));
362  edgeUse0 = add_adj(model, b, vertexMap[2]);
363  edgeUse0_1 = add_adj(model,b,vertexMap[6]);
364  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
365  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
366 
367  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_edge[11]));
368  edgeUse0 = add_adj(model, b, vertexMap[3]);
369  edgeUse0_1 = add_adj(model,b,vertexMap[7]);
370  gmi_add_analytic_reparam(model, edgeUse0, reparamVert_zero, 0);
371  gmi_add_analytic_reparam(model, edgeUse0_1, reparamVert_one, 0);
372 
373  //make faces
374 
375  int facePeriodic[2] = {0, 0};
376  double faceRanges[2][2] = {{0,1.0},{0,1.0}};
377  gmi_ent* g_face[6];
378  g_face[0] = gmi_add_analytic(model, 2, 80, face0, facePeriodic, faceRanges, 0);
379  g_face[1] = gmi_add_analytic(model, 2, 78, face1, facePeriodic, faceRanges, 0);
380  g_face[2] = gmi_add_analytic(model, 2, 76, face2, facePeriodic, faceRanges, 0);
381  g_face[3] = gmi_add_analytic(model, 2, 82, face3, facePeriodic, faceRanges, 0);
382  g_face[4] = gmi_add_analytic(model, 2, 42, face4, facePeriodic, faceRanges, 0);
383  g_face[5] = gmi_add_analytic(model, 2, 24, face5, facePeriodic, faceRanges, 0);
384 
385  //reparam edges onto face
386 
387  //int edgeMap[12] = {50,48,46,52,11,16,20,6,73,72,71,74};
388  int edgeLoop[6][4] = {{50,72,11,73},{72,48,71,16},{46,74,20,71},{52,73,6,74},{50,52,46,48},{11,16,20,6}};
389  int edgeReparamLoop[6][4] = {{0,3,2,1},{1,0,3,2},{0,1,2,3},{0,1,2,3},{0,1,2,3},{0,3,2,1}};
390  //int faceLoop[6] = {80,78,76,82,42,24};
391 
392  //int faceMap[6] = {0,1,2,3,4,5};
393  //int faceLoop[6][4] = {{0,9,4,8},{9,1,10,5},{2,11,6,10},{3,8,7,11},{0,3,2,1},{4,5,6,7}};
394 
395 /*
396  typedef void (*ParametricFunctionArray) (double const p[2], double x[3], void*);
397  ParametricFunctionArray faceFunction[] =
398  {
399  face0,
400  face1,
401  face2,
402  face3,
403  face4,
404  face5,
405  };
406  for(int i=0; i<6;i++)
407  {
408  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_face[i]));
409  for(int j=0; j<4;j++)
410  {
411  agm_use faceUse = add_adj(model, b, edgeLoop[i][j]);
412  gmi_add_analytic_reparam(model, faceUse, faceFunction[i], 0);
413  }
414  }
415 
416 
417 */
418 
419  typedef void (*ParametricFunctionArray) (double const from[2], double to[2], void*);
420  ParametricFunctionArray edgeFaceFunction[] =
421  {
426  };
427 
428  for(int i=0; i<6;i++)
429  {
430  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_face[i]));
431  for(int j=0; j<4;j++)
432  {
433  agm_use faceUse = add_adj(model, b, edgeLoop[i][j]);
434  gmi_add_analytic_reparam(model, faceUse, edgeFaceFunction[edgeReparamLoop[i][j]], 0);
435  }
436  }
437 
438 
439  //make region
440 /*
441  int regionPeriodic[3] = {0, 0, 0};
442  double regionRanges[3][2] = {{0,0},{0,0},{0.0}};
443  gmi_ent* g_region;
444  g_region = gmi_add_analytic(model, 3, 92, regionFunction, regionPeriodic, regionRanges, 0);
445  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(g_region));
446 */
447  gmi_add_analytic_cell(model,3,92);
448 
449  b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(gmi_find(model,3,92)));
450  for(int i=0; i<6;i++)
451  {
452  agm_use regionUse = add_adj(model, b, faceLoop[i]);
453  gmi_add_analytic_reparam(model, regionUse, regionFunction, 0);
454  }
455 
456 /*
457  //add edge adjacencies to region?
458  it doesn't seem like i need to do this
459  for(int i=0;i<12;i++)
460  {
461  agm_use regionUse = add_adj(model,b,1,edgeMap[i]);
462  gmi_add_analytic_reparam(model, regionUse, regionFunction, 0);
463  }
464 */
465 
466  //get the sphere reparameterizations onto box
467  //b = agm_add_bdry(gmi_analytic_topo(model), agm_from_gmi(gmi_find(model,3,92)));
468  agm_use regionUse = add_adj(model, b, 123);
469  gmi_add_analytic_reparam(model, regionUse, regionFunction, 0);
470 
471 
472  return;
473 }
474 
475 
476 //create sphere
477 const double pi = apf::pi;
478 int sphereFaceID = 123;
480 double xyz_offset[3];
481 
482 void sphereFace(double const p[2], double x[3], void*)
483 {
484  x[0] = xyz_offset[0]+sphereRadius*cos(p[0]) * sin(p[1]);
485  x[1] = xyz_offset[1]+sphereRadius*sin(p[0]) * sin(p[1]);
486  x[2] = xyz_offset[2]+sphereRadius*cos(p[1]);
487 }
488 
489 void makeSphere(gmi_model* model)
490 {
491  int faPer[2] = {1, 0};
492  double faRan[2][2] = {{0,6.28318530718},{0.0,apf::pi}};
493 
494  gmi_add_analytic(model, 2, sphereFaceID, sphereFace, faPer, faRan, 0);
495 }
496 
497 void setParameterization(gmi_model* model,apf::Mesh2* m)
498 {
499 
500  //Get the classification of each entity in the SimMesh
501  apf::MeshEntity* ent;
502  for(int i =0;i<4;i++)
503  {
504  apf::MeshIterator* it = m->begin(i);
505  while( (ent = m->iterate(it)))
506  {
507  apf::ModelEntity* g_ent = m->toModel(ent);
508  int modelTag = m->getModelTag(g_ent);
509  int modelType = m->getModelType(g_ent);
510  if(modelTag > 139 && modelTag< 148)
511  {
512  m->setModelEntity(ent,(apf::ModelEntity*)gmi_find(model,modelType,sphereFaceID));
513  }
514  else
515  m->setModelEntity(ent,(apf::ModelEntity*)gmi_find(model,modelType,modelTag));
516 
517  }
518  m->end(it);
519  }
520  m->setModel(model);
521  m->acceptChanges();
522 
523  //Need to set the parametric coordinates of each of the boundary vertices
524  std::map<int,int> edgeParam;
525  int edgeScales[12] = {0,1,0,1,0,1,0,1,2,2,2,2};
526  double edgeLengths[3] = {boxLength,boxWidth,boxHeight};
527  for(int i=0;i<12;i++)
528  {
529  edgeParam[edgeMap[i]] = edgeScales[i];
530  }
531 
532  std::map<int,int(*)[2]> faceParam;
533  int faceScales[6][2] = {{0,2},{1,2},{0,2},{1,2},{0,1},{0,1}};
534  for(int i = 0; i<6;i++)
535  {
536  faceParam[faceLoop[i]] = &(faceScales[i]);
537  }
538 
539  apf::MeshIterator* it = m->begin(0);
540  while( (ent = m->iterate(it)) )
541  {
542  apf::ModelEntity* g_ent = m->toModel(ent);
543 
544  apf::MeshEntity* ev[2];
545  m->getDownward(ent,0,ev);
546  int modelTag = m->getModelTag(g_ent);
547  int modelType = m->getModelType(g_ent);
548  if(modelType<3 && modelType!=0)
549  {
550  apf::Vector3 pt;
551  apf::Vector3 oldParam;
552  apf::Vector3 newParam;
553  m->getPoint(ent,0,pt);
554  m->getParam(ent,oldParam);
555  if(modelType==1)
556  {
557  int relevantIndex = edgeParam[modelTag];
558  newParam[0]=pt[relevantIndex]/edgeLengths[relevantIndex];
559  m->setParam(ent,newParam);
560  }
561  else if (modelType==2 && modelTag!=sphereFaceID)
562  {
563  int* relevantIndex = faceParam[modelTag][0]; //size is 2
564  newParam[0] = pt[relevantIndex[0]]/edgeLengths[relevantIndex[0]];
565  newParam[1] = pt[relevantIndex[1]]/edgeLengths[relevantIndex[1]];
566  m->setParam(ent,newParam);
567  }
568  else if (modelType==2 && modelTag == sphereFaceID)
569  {
570  double argy = (pt[1]-xyz_offset[1]);
571  double argx = (pt[0]-xyz_offset[0]);
572  if(argx == 0 && argy ==0)
573  newParam[0] = 0.0; // not sure if this will happen or if this is right
574  else
575  newParam[0] = atan2(argy,argx);
576  double arg2 = (pt[2]-xyz_offset[2])/sphereRadius;
577  if(arg2 < -1.0)
578  arg2 = -1.0;
579  else if (arg2 > 1.0)
580  arg2 = 1.0;
581 
582  newParam[1] = acos(arg2);
583  if(newParam[0]<0)
584  newParam[0] = newParam[0]+2*apf::pi;
585  if(newParam[0]>2*apf::pi)
586  newParam[0] = newParam[0]-2*apf::pi;
587 
588  //this is probably unnecessary
589  if(newParam[1]<0.0)
590  newParam[1] = -1*newParam[1];
591  if(newParam[1]>apf::pi)
592  newParam[1] = -1*(newParam[1]-2.0*apf::pi);
593 
594  m->setParam(ent,newParam);
595  }
596  } //end if
597  } //end while
598  m->end(it);
599  m->acceptChanges();
600 }
601 
602 gmi_model* MeshAdaptPUMIDrvr::createSphereInBox(double* boxDim,double*sphereCenter, double radius)
603 {
604  sphereRadius = radius;
605  boxLength = boxDim[0];
606  boxWidth = boxDim[1];
607  boxHeight = boxDim[2];
608  xyz_offset[0] = sphereCenter[0];
609  xyz_offset[1] = sphereCenter[1];
610  xyz_offset[2] = sphereCenter[2];
611 
612  lion_set_verbosity(1);
613 
614  //create the analytic model
615  gmi_model* model = gmi_make_analytic();
616 
617  //add the sphere
618 
619  makeSphere(model);
620 
621  //add the box
622  makeBox(model);
623 
624  //apf::writeVtkFiles("initialInitial",m);
625  setParameterization(model,m);
626  m->verify();
627 
628  //apf::Field* size_initial = apf::createLagrangeField(m,"size_initial",apf::SCALAR,1);
629  size_iso = apf::createLagrangeField(m,"proteus_size",apf::SCALAR,1);
630  apf::MeshIterator* it = m->begin(0);
631  apf::MeshEntity* ent;
632  while( (ent = m->iterate(it)) )
633  {
634  apf::Vector3 pt;
635  m->getPoint(ent,0,pt);
636  if(sqrt( (pt[0]-xyz_offset[0])*(pt[0]-xyz_offset[0])+ (pt[1]-xyz_offset[1])*(pt[1]-xyz_offset[1]) + (pt[2]-xyz_offset[2])*(pt[2]-xyz_offset[2])) < sphereRadius*1.5)
637  apf::setScalar(size_iso,ent,0,hmin);
638  else
639  apf::setScalar(size_iso,ent,0,hmax);
640  }
641  m->end(it);
642 
643  gradeMesh(1.5);
644 
645 
646  ma::Input* in = ma::makeAdvanced(ma::configure(m,size_iso));
647  in->maximumIterations = 10;
648  in->shouldSnap = true;
649  in->shouldTransferParametric = true;
650  in->shouldFixShape = true;
651  in->debugFolder="./debug_fine";
652  ma::adaptVerbose(in,false);
653  m->verify();
654 
655  //apf::writeVtkFiles("initialAdapt",m);
656  freeField(size_iso);
657 
658  size_iso = apf::createLagrangeField(m,"proteus_size",apf::SCALAR,1);
659  it = m->begin(0);
660  while( (ent = m->iterate(it)) )
661  {
662  apf::Vector3 pt;
663  m->getPoint(ent,0,pt);
664  if(sqrt( (pt[0]-xyz_offset[0])*(pt[0]-xyz_offset[0])+ (pt[1]-xyz_offset[1])*(pt[1]-xyz_offset[1]) + (pt[2]-xyz_offset[2])*(pt[2]-xyz_offset[2])) < sphereRadius*1.5)
665  apf::setScalar(size_iso,ent,0,hmin);
666  else
667  apf::setScalar(size_iso,ent,0,hmax);
668  }
669  m->end(it);
670 
671  gradeMesh(1.5);
672 
673  in = ma::makeAdvanced(ma::configure(m,size_iso));
674  in->maximumIterations = 10;
675  in->shouldSnap = true;
676  in->shouldTransferParametric = true;
677  in->shouldFixShape = true;
678  in->debugFolder="./debug_fine";
679  ma::adaptVerbose(in,false);
680  m->verify();
681 
682  //apf::writeVtkFiles("initialAdapt2",m);
683  freeField(size_iso);
684 
685  return model;
686 }
687 
688 
689 
691 {
692  xyz_offset[0] = sphereCenter[0];
693  xyz_offset[1] = sphereCenter[1];
694  xyz_offset[2] = sphereCenter[2];
695 }
696 
697 
edge8
void edge8(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:148
face4
void face4(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:203
MeshAdaptPUMIDrvr::hmin
double hmin
Definition: MeshAdaptPUMI.h:91
reparamEdge_2
void reparamEdge_2(double const from[2], double to[2], void *)
Definition: createAnalyticGeometry.cpp:241
MeshAdaptPUMI.h
regionFunction
void regionFunction(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:257
face5
void face5(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:209
makeBox
void makeBox(gmi_model *model)
Definition: createAnalyticGeometry.cpp:264
MeshAdaptPUMIDrvr::updateSphereCoordinates
void updateSphereCoordinates(double *sphereCenter)
Definition: createAnalyticGeometry.cpp:690
vert1
void vert1(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:36
edge1
void edge1(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:99
MeshAdaptPUMIDrvr::hmax
double hmax
Definition: MeshAdaptPUMI.h:91
face2
void face2(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:190
edge0
void edge0(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:92
boxLength
double boxLength
Definition: createAnalyticGeometry.cpp:21
edge9
void edge9(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:155
edge5
void edge5(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:127
vert2
void vert2(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:44
reparamEdge_1
void reparamEdge_1(double const from[2], double to[2], void *)
Definition: createAnalyticGeometry.cpp:236
MeshAdaptPUMIDrvr::createSphereInBox
gmi_model * createSphereInBox(double *boxDim, double *sphereCenter, double radius)
Definition: createAnalyticGeometry.cpp:602
edge4
void edge4(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:120
edge6
void edge6(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:134
edge11
void edge11(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:169
edgeMap
int edgeMap[12]
Definition: createAnalyticGeometry.cpp:24
add_adj
agm_use add_adj(gmi_model *m, agm_bdry b, int tag)
Definition: createAnalyticGeometry.cpp:13
boxHeight
double boxHeight
Definition: createAnalyticGeometry.cpp:23
faceLoop
int faceLoop[6]
Definition: createAnalyticGeometry.cpp:25
edge3
void edge3(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:113
vert5
void vert5(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:68
face0
void face0(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:176
setParameterization
void setParameterization(gmi_model *model, apf::Mesh2 *m)
Definition: createAnalyticGeometry.cpp:497
sphereFace
void sphereFace(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:482
reparamVert_zero
void reparamVert_zero(double const from[2], double to[2], void *)
Definition: createAnalyticGeometry.cpp:216
vert6
void vert6(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:76
edge10
void edge10(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:162
xyz_offset
double xyz_offset[3]
Definition: createAnalyticGeometry.cpp:480
edge2
void edge2(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:106
vert0
void vert0(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:28
vert7
void vert7(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:84
face1
void face1(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:183
makeSphere
void makeSphere(gmi_model *model)
Definition: createAnalyticGeometry.cpp:489
add_bdry
agm_bdry add_bdry(gmi_model *m, gmi_ent *e)
Definition: createAnalyticGeometry.cpp:8
sphereFaceID
int sphereFaceID
Definition: createAnalyticGeometry.cpp:478
boxWidth
double boxWidth
Definition: createAnalyticGeometry.cpp:22
edge7
void edge7(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:141
vert3
void vert3(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:52
createAnalyticGeometry.h
reparamEdge_0
void reparamEdge_0(double const from[2], double to[2], void *)
Definition: createAnalyticGeometry.cpp:230
pi
const double pi
Definition: createAnalyticGeometry.cpp:477
sphereRadius
double sphereRadius
Definition: createAnalyticGeometry.cpp:479
reparamEdge_3
void reparamEdge_3(double const from[2], double to[2], void *)
Definition: createAnalyticGeometry.cpp:247
face3
void face3(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:197
MeshAdaptPUMIDrvr::gradeMesh
int gradeMesh(double gradationFactor)
Definition: SizeField.cpp:1660
reparamVert_one
void reparamVert_one(double const from[2], double to[2], void *)
Definition: createAnalyticGeometry.cpp:222
vert4
void vert4(double const p[2], double x[3], void *)
Definition: createAnalyticGeometry.cpp:60