52 #include "Shards_CellTopology.hpp"
53 #include "Teuchos_GlobalMPISession.hpp"
56 using namespace Intrepid;
57 using namespace shards;
59 int main(
int argc,
char *argv[]) {
61 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
64 <<
"===============================================================================\n" \
66 <<
"| Example use of the CellTools class |\n" \
68 <<
"| 1) Using shards::CellTopology to get cell types and topology |\n" \
69 <<
"| 2) Using CellTools to get cell Jacobians and their inverses and dets |\n" \
70 <<
"| 3) Testing points for inclusion in reference and physical cells |\n" \
71 <<
"| 4) Mapping points to and from reference cells with base and extended |\n" \
72 <<
"| topologies. |\n" \
74 <<
"| Questions? Contact Pavel Bochev (pbboche@sandia.gov) or |\n" \
75 <<
"| Denis Ridzal (dridzal@sandia.gov) |\n" \
76 <<
"| Kara Peterson (kjpeter@sandia.gov). |\n" \
78 <<
"| Intrepid's website: http://trilinos.sandia.gov/packages/intrepid |\n" \
79 <<
"| Shards's website: http://trilinos.sandia.gov/packages/shards |\n" \
80 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" \
82 <<
"===============================================================================\n"\
83 <<
"| EXAMPLE 1: Query of cell types and topology |\n"\
84 <<
"===============================================================================\n";
89 typedef shards::CellTopology CellTopology;
93 std::vector<CellTopology> shardsTopologies;
98 shards::getTopologies(shardsTopologies, cellDim);
99 std::cout <<
"Number of all " << cellDim
100 <<
"D Shards cell topologies = " << shardsTopologies.size() <<
"\n\n";
102 for(
unsigned i = 0; i < shardsTopologies.size(); i++){
103 std::cout << shardsTopologies[i].getName() <<
"\n";
109 shards::getTopologies(shardsTopologies, cellDim,
110 shards::STANDARD_CELL);
111 std::cout <<
"Number of all "
112 << cellDim <<
"D standard Shards cell topologies = " << shardsTopologies.size() <<
"\n\n";
114 for(
unsigned i = 0; i < shardsTopologies.size(); i++){
115 std::cout << shardsTopologies[i].getName() <<
"\n";
121 shards::getTopologies(shardsTopologies, cellDim,
122 shards::STANDARD_CELL,
123 shards::BASE_TOPOLOGY);
124 std::cout <<
"Number of all " << cellDim
125 <<
"D standard Shards cells with base topologies = " << shardsTopologies.size() <<
"\n\n";
127 for(
unsigned i = 0; i < shardsTopologies.size(); i++){
128 std::cout << shardsTopologies[i].getName() <<
"\n";
134 shards::getTopologies(shardsTopologies, cellDim,
135 shards::STANDARD_CELL,
136 shards::EXTENDED_TOPOLOGY);
137 std::cout <<
"Number of all " << cellDim
138 <<
"D standard Shards cells with extended topologies = " << shardsTopologies.size() <<
"\n\n";
140 for(
unsigned i = 0; i < shardsTopologies.size(); i++){
141 std::cout << shardsTopologies[i].getName() <<
"\n";
147 shards::getTopologies(shardsTopologies, cellDim,
148 shards::NONSTANDARD_CELL,
149 shards::BASE_TOPOLOGY);
150 std::cout <<
"Number of all " << cellDim
151 <<
"D non-standard Shards cells with base topologies = " << shardsTopologies.size() <<
"\n\n";
153 for(
unsigned i = 0; i < shardsTopologies.size(); i++){
154 std::cout << shardsTopologies[i].getName() <<
"\n";
160 shards::getTopologies(shardsTopologies, cellDim,
161 shards::NONSTANDARD_CELL,
162 shards::EXTENDED_TOPOLOGY);
163 std::cout <<
"Number of all " << cellDim
164 <<
"D non-standard Shards cells with extended topologies = " << shardsTopologies.size() <<
"\n\n";
166 for(
unsigned i = 0; i < shardsTopologies.size(); i++){
167 std::cout << shardsTopologies[i].getName() <<
"\n";
172 shards::getTopologies(shardsTopologies);
173 std::cout <<
"Number of all Shards cell topologies = " << shardsTopologies.size() <<
"\n\n";
174 for(
unsigned i = 0; i < shardsTopologies.size(); i++){
175 std::cout << shardsTopologies[i] <<
"\n";
182 <<
"===============================================================================\n"\
183 <<
"| EXAMPLE 2: Using CellTools to get Jacobian, Jacobian inverse & Jacobian det |\n"\
184 <<
"===============================================================================\n";
187 CellTopology triangle_3(shards::getCellTopologyData<Triangle<3> >() );
189 int numNodes = triangle_3.getNodeCount();
190 int spaceDim = triangle_3.getDimension();
196 triNodes(0, 0, 0) = 0.0; triNodes(0, 0, 1) = 0.0;
197 triNodes(0, 1, 0) = 1.0; triNodes(0, 1, 1) = 0.0;
198 triNodes(0, 2, 0) = 0.0; triNodes(0, 2, 1) = 1.0;
200 triNodes(1, 0, 0) = 1.0; triNodes(1, 0, 1) = 1.0;
201 triNodes(1, 1, 0) = 2.0; triNodes(1, 1, 1) = 1.0;
202 triNodes(1, 2, 0) = 1.0; triNodes(1, 2, 1) = 2.0;
204 triNodes(2, 0, 0) = 0.0; triNodes(2, 0, 1) = 0.0;
205 triNodes(2, 1, 0) =-1.0; triNodes(2, 1, 1) = 0.0;
206 triNodes(2, 2, 0) = 0.0; triNodes(2, 2, 1) = 1.0;
208 triNodes(3, 0, 0) = 2.0; triNodes(3, 0, 1) = 1.0;
209 triNodes(3, 1, 0) = 3.0; triNodes(3, 1, 1) = 0.5;
210 triNodes(3, 2, 0) = 3.5; triNodes(3, 2, 1) = 2.0;
214 int numRefPoints = 2;
216 refPoints(0,0) = 0.0; refPoints(0,1) = 0.0;
217 refPoints(1,0) = 0.5; refPoints(1,1) = 0.5;
231 CellTools::setJacobian(triJacobian, refPoints, triNodes, triangle_3);
232 CellTools::setJacobianInv(triJacobInv, triJacobian );
233 CellTools::setJacobianDet(triJacobDet, triJacobian );
236 RealSpaceTools::det(rank2Aux, triJacobInv);
237 RealSpaceTools::inverse(rank4Aux, triJacobInv);
241 << std::scientific<< std::setprecision(4)
242 << std::right << std::setw(16) <<
"DF(P)"
243 << std::right << std::setw(30) <<
"Inv(DF(P))"
244 << std::right << std::setw(30) <<
"Inv(Inv(DF(P)))\n";
246 for(
int cellOrd = 0; cellOrd < numCells; cellOrd++){
248 <<
"===============================================================================\n"
249 <<
"Cell " << cellOrd <<
"\n";
250 for(
int pointOrd = 0; pointOrd < numRefPoints; pointOrd++){
251 std::cout <<
"Point = ("
252 << std::setw(4) << std::right << refPoints(pointOrd, 0) <<
","<< std::setw(4) << std::right<< refPoints(pointOrd,1) <<
")\n";
253 for(
int row = 0; row < spaceDim; row++){
255 << std::setw(11) << std::right << triJacobian(cellOrd, pointOrd, row, 0) <<
" "
256 << std::setw(11) << std::right << triJacobian(cellOrd, pointOrd, row, 1)
258 << std::setw(16) << std::right << triJacobInv(cellOrd, pointOrd, row, 0) <<
" "
259 << std::setw(11) << std::right << triJacobInv(cellOrd, pointOrd, row, 1)
261 << std::setw(16) << std::right << rank4Aux(cellOrd, pointOrd, row, 0) <<
" "
262 << std::setw(11) << std::right << rank4Aux(cellOrd, pointOrd, row, 1) <<
"\n";
265 << setw(5)<<std::left<<
"Determinant:\n"
266 << std::setw(11) << std::right << triJacobDet(cellOrd, pointOrd)
267 << std::setw(28) << std::right << rank2Aux(cellOrd, pointOrd)
268 << std::setw(28) << std::right <<
" product = " << triJacobDet(cellOrd, pointOrd)*rank2Aux(cellOrd, pointOrd);
275 CellTopology quad_4(shards::getCellTopologyData<Quadrilateral<4> >() );
277 numNodes = quad_4.getNodeCount();
278 spaceDim = quad_4.getDimension();
282 quadNodes(0,0,0) = 1.00; quadNodes(0,0,1) = 1.00;
283 quadNodes(0,1,0) = 2.00; quadNodes(0,1,1) = 0.75;
284 quadNodes(0,2,0) = 1.75; quadNodes(0,2,1) = 2.00;
285 quadNodes(0,3,0) = 1.25; quadNodes(0,3,1) = 2.00,
287 quadNodes(1,0,0) = 2.00; quadNodes(1,0,1) = 0.75;
288 quadNodes(1,1,0) = 3.00; quadNodes(1,1,1) = 1.25;
289 quadNodes(1,2,0) = 2.75; quadNodes(1,2,1) = 2.25;
290 quadNodes(1,3,0) = 1.75; quadNodes(1,3,1) = 2.00;
295 CellTopology hex_8(shards::getCellTopologyData<Hexahedron<8> >() );
297 numNodes = hex_8.getNodeCount();
298 spaceDim = hex_8.getDimension();
303 hexNodes(0,0,0) = 1.00; hexNodes(0,0,1) = 1.00; hexNodes(0,0,2) = 0.00;
304 hexNodes(0,1,0) = 2.00; hexNodes(0,1,1) = 0.75; hexNodes(0,1,2) =-0.25;
305 hexNodes(0,2,0) = 1.75; hexNodes(0,2,1) = 2.00; hexNodes(0,2,2) = 0.00;
306 hexNodes(0,3,0) = 1.25; hexNodes(0,3,1) = 2.00; hexNodes(0,3,1) = 0.25;
308 hexNodes(0,4,0) = 1.25; hexNodes(0,4,1) = 0.75; hexNodes(0,4,2) = 0.75;
309 hexNodes(0,5,0) = 1.75; hexNodes(0,5,1) = 1.00; hexNodes(0,5,2) = 1.00;
310 hexNodes(0,6,0) = 2.00; hexNodes(0,6,1) = 2.00; hexNodes(0,6,2) = 1.25;
311 hexNodes(0,7,0) = 1.00; hexNodes(0,7,1) = 2.00; hexNodes(0,7,2) = 1.00;
315 std::cout << std::setprecision(16) <<
"\n" \
316 <<
"===============================================================================\n"\
317 <<
"| EXAMPLE 3: Using single point inclusion test method |\n"\
318 <<
"===============================================================================\n";
321 CellTopology edge3(shards::getCellTopologyData<Line<3> >() );
322 CellTopology tri6 (shards::getCellTopologyData<Triangle<6> >() );
323 CellTopology quad9(shards::getCellTopologyData<Quadrilateral<9> >() );
324 CellTopology tet4 (shards::getCellTopologyData<Tetrahedron<> >() );
325 CellTopology hex27(shards::getCellTopologyData<Hexahedron<27> >() );
326 CellTopology wedge(shards::getCellTopologyData<Wedge<> >() );
327 CellTopology pyr (shards::getCellTopologyData<Pyramid<> >() );
330 double point_in_edge[1] = {1.0-INTREPID_EPSILON};
331 double point_in_quad[2] = {1.0, 1.0-INTREPID_EPSILON};
332 double point_in_tri[2] = {0.5-INTREPID_EPSILON, 0.5-INTREPID_EPSILON};
333 double point_in_tet[3] = {0.5-INTREPID_EPSILON, 0.5-INTREPID_EPSILON, 2.0*INTREPID_EPSILON};
334 double point_in_hex[3] = {1.0-INTREPID_EPSILON, 1.0-INTREPID_EPSILON, 1.0-INTREPID_EPSILON};
335 double point_in_wedge[3] = {0.5, 0.25, 1.0-INTREPID_EPSILON};
336 double point_in_pyramid[3] = {-INTREPID_EPSILON, INTREPID_EPSILON, 1.0-INTREPID_EPSILON};
339 int in_edge = CellTools::checkPointInclusion( point_in_edge, 1, edge3, INTREPID_THRESHOLD );
340 int in_quad = CellTools::checkPointInclusion( point_in_quad, 2, quad9 );
341 int in_tri = CellTools::checkPointInclusion( point_in_tri, 2, tri6 );
342 int in_tet = CellTools::checkPointInclusion( point_in_tet, 3, tet4 );
343 int in_hex = CellTools::checkPointInclusion( point_in_hex, 3, hex27 );
344 int in_prism = CellTools::checkPointInclusion( point_in_wedge, 3, wedge );
345 int in_pyramid = CellTools::checkPointInclusion( point_in_pyramid, 3, pyr );
348 std::cout <<
"(" << point_in_edge[0] <<
")"
349 <<
" is inside reference Line " << endl;
352 std::cout <<
"(" << point_in_quad[0] <<
"," << point_in_quad[1] <<
")"
353 <<
" is inside reference Quadrilateral " << endl;
356 std::cout <<
"(" << point_in_tri[0] <<
"," << point_in_tri[1] <<
")"
357 <<
" is inside reference Triangle " << endl;
360 std::cout <<
"(" << point_in_tet[0] <<
"," << point_in_tet[1] <<
"," << point_in_tet[2]<<
")"
361 <<
" is inside reference Tetrahedron " << endl;
364 std::cout <<
"(" << point_in_hex[0] <<
"," << point_in_hex[1] <<
"," << point_in_hex[2]<<
")"
365 <<
" is inside reference Hexahedron " << endl;
368 std::cout <<
"(" << point_in_wedge[0] <<
"," << point_in_wedge[1] <<
"," << point_in_wedge[2]<<
")"
369 <<
" is inside reference Wedge " << endl;
372 std::cout <<
"(" << point_in_pyramid[0] <<
"," << point_in_pyramid[1] <<
"," << point_in_pyramid[2]<<
")"
373 <<
" is inside reference Pyramid " << endl;
377 double small = 2.0*INTREPID_THRESHOLD;
378 point_in_edge[0] += small;
380 point_in_tri[0] += small;
381 point_in_tri[1] += small;
383 point_in_pyramid[0] += small;
384 point_in_pyramid[1] += small;
385 point_in_pyramid[2] += small;
387 in_edge = CellTools::checkPointInclusion(point_in_edge, 1, edge3);
388 in_tri = CellTools::checkPointInclusion(point_in_tri, 2, tri6);
389 in_pyramid = CellTools::checkPointInclusion(point_in_pyramid, 3, pyr);
391 std::cout <<
"\nChecking if perturbed Points belong to reference cell: " << endl;
393 std::cout <<
"(" << point_in_edge[0] <<
")" <<
" is NOT inside reference Line " << endl;
396 std::cout <<
"(" << point_in_tri[0] <<
"," << point_in_tri[1] <<
")" <<
" is NOT inside reference Triangle " << endl;
399 std::cout <<
"(" << point_in_pyramid[0] <<
"," << point_in_pyramid[1] <<
"," << point_in_pyramid[2]<<
")"
400 <<
" is NOT inside reference Pyramid " << endl;
405 std::cout << std::setprecision(6) <<
"\n" \
406 <<
"===============================================================================\n"\
407 <<
"| EXAMPLE 4-A: Using pointwise inclusion test method for reference cells |\n"\
408 <<
"===============================================================================\n";
415 onePoint(0) = 0.2; onePoint(1) = 0.3;
417 std::cout <<
"\t Pointwise inclusion test for Triangle<6>: rank-1 array with a single 2D point: \n";
419 CellTools::checkPointwiseInclusion(testOnePoint, onePoint, tri6);
421 std::cout <<
"point("
422 << std::setw(13) << std::right << onePoint(0) <<
","
423 << std::setw(13) << std::right << onePoint(1) <<
") ";
424 if( testOnePoint(0) ) {
425 std::cout <<
" is inside. \n";
428 std::cout <<
" is not inside. \n";
437 fourPoints(0,0) = 0.5; fourPoints(0,1) = 0.5;
438 fourPoints(1,0) = 1.0; fourPoints(1,1) = 1.1;
439 fourPoints(2,0) =-1.0; fourPoints(2,1) =-1.1;
440 fourPoints(3,0) =-1.0; fourPoints(3,1) = 0.5;
442 std::cout <<
"\t Pointwise inclusion test for Quadrilateral<9>: rank-2 array with 4 2D points: \n";
444 CellTools::checkPointwiseInclusion(testFourPoints, fourPoints, quad9);
446 for(
int i1 = 0; i1 < fourPoints.dimension(0); i1++) {
447 std::cout <<
" point(" << i1 <<
") = ("
448 << std::setw(13) << std::right << fourPoints(i1, 0) <<
","
449 << std::setw(13) << std::right << fourPoints(i1, 1) <<
") ";
450 if( testFourPoints(i1) ) {
451 std::cout <<
" is inside. \n";
454 std::cout <<
" is not inside. \n";
464 sixPoints(0,0,0) = -1.0; sixPoints(0,0,1) = 1.0;
465 sixPoints(0,1,0) = 1.0; sixPoints(0,1,1) = 0.0;
466 sixPoints(0,2,0) = 0.0; sixPoints(0,2,1) = 1.0;
467 sixPoints(1,0,0) = -1.0; sixPoints(1,0,1) = -1.0;
468 sixPoints(1,1,0) = 0.1; sixPoints(1,1,1) = 0.2;
469 sixPoints(1,2,0) = 0.2; sixPoints(1,2,1) = 0.3;
471 std::cout <<
"\t Pointwise inclusion test for Triangle<6>: rank-3 array with six 2D points: \n";
473 CellTools::checkPointwiseInclusion(testSixPoints, sixPoints, tri6);
475 for(
int i0 = 0; i0 < sixPoints.dimension(0); i0++){
476 for(
int i1 = 0; i1 < sixPoints.dimension(1); i1++) {
477 std::cout <<
" point(" << i0 <<
"," << i1 <<
") = ("
478 << std::setw(13) << std::right << sixPoints(i0, i1, 0) <<
","
479 << std::setw(13) << std::right << sixPoints(i0, i1, 1) <<
") ";
480 if( testSixPoints(i0, i1) ) {
481 std::cout <<
" is inside. \n";
484 std::cout <<
" is not inside. \n";
496 six3DPoints(0,0,0) = -1.0; six3DPoints(0,0,1) = 1.0; six3DPoints(0,0,2) = 1.0;
497 six3DPoints(0,1,0) = 1.0; six3DPoints(0,1,1) = 1.0; six3DPoints(0,1,2) = -1.0;
498 six3DPoints(0,2,0) = 0.0; six3DPoints(0,2,1) = 1.1; six3DPoints(0,2,2) = 1.0;
499 six3DPoints(1,0,0) = -1.1; six3DPoints(1,0,1) = -1.0; six3DPoints(1,0,2) = -1.0;
500 six3DPoints(1,1,0) = 0.1; six3DPoints(1,1,1) = 0.2; six3DPoints(1,1,2) = 0.2;
501 six3DPoints(1,2,0) = 1.1; six3DPoints(1,2,1) = 0.3; six3DPoints(1,2,2) = 0.3;
503 std::cout <<
"\t Pointwise inclusion test for Hexahedron<27>: rank-3 array with six 3D points: \n";
505 CellTools::checkPointwiseInclusion(testSix3DPoints, six3DPoints, hex27);
509 for(
int i0 = 0; i0 < six3DPoints.dimension(0); i0++){
510 for(
int i1 = 0; i1 < six3DPoints.dimension(1); i1++) {
511 std::cout <<
" point(" << i0 <<
"," << i1 <<
") = ("
512 << std::setw(13) << std::right << six3DPoints(i0, i1, 0) <<
","
513 << std::setw(13) << std::right << six3DPoints(i0, i1, 1) <<
","
514 << std::setw(13) << std::right << six3DPoints(i0, i1, 2) <<
") ";
515 if( testSix3DPoints(i0, i1) ) {
516 std::cout <<
" is inside. \n";
519 std::cout <<
" is not inside. \n";
525 std::cout << std::setprecision(6) <<
"\n" \
526 <<
"===============================================================================\n"\
527 <<
"| EXAMPLE 4-B: Pointwise inclusion test for a physical cell in cell workset |\n"\
528 <<
"===============================================================================\n";
535 fivePoints(0, 0) = 2.1 ; fivePoints(0, 1) = 1.0 ;
536 fivePoints(1, 0) = 3.0 ; fivePoints(1, 1) = 0.75;
537 fivePoints(2, 0) = 3.5 ; fivePoints(2, 1) = 1.9 ;
538 fivePoints(3, 0) = 2.5 ; fivePoints(3, 1) = 1.0 ;
539 fivePoints(4, 0) = 2.75; fivePoints(4, 1) = 2.0 ;
541 CellTools::checkPointwiseInclusion(testFivePoints, fivePoints, triNodes, triangle_3, 3);
543 std::cout <<
" Vertices of Triangle #3: \n"
544 <<
"\t(" << triNodes(3, 0, 0) <<
", " << triNodes(3, 0, 1) <<
")\n"
545 <<
"\t(" << triNodes(3, 1, 0) <<
", " << triNodes(3, 1, 1) <<
")\n"
546 <<
"\t(" << triNodes(3, 1, 0) <<
", " << triNodes(3, 1, 1) <<
")\n"
547 <<
" Inclusion test results for the physical points: \n\n";
549 for(
int i1 = 0; i1 < fivePoints.dimension(0); i1++) {
550 std::cout <<
" point(" << i1 <<
") = ("
551 << std::setw(13) << std::right << fivePoints(i1, 0) <<
","
552 << std::setw(13) << std::right << fivePoints(i1, 1) <<
") ";
553 if( testFivePoints(i1) ) {
554 std::cout <<
" is inside. \n";
557 std::cout <<
" is not inside. \n";
564 std::cout << std::setprecision(6) <<
"\n" \
565 <<
"===============================================================================\n"\
566 <<
"| EXAMPLE 4-C: Pointwise inclusion test for all physical cells in cell workset|\n"\
567 <<
"===============================================================================\n";
574 fourPointSets(0, 0, 0) = 0.25; fourPointSets(0, 0, 1) = 0.75;
575 fourPointSets(0, 1, 0) = 0.00; fourPointSets(0, 1, 1) =-0.01;
578 fourPointSets(1, 0, 0) = 1.50; fourPointSets(1, 0, 1) = 1.50;
579 fourPointSets(1, 1, 0) = 0.99; fourPointSets(1, 1, 1) = 1.50;
582 fourPointSets(2, 0, 0) =-0.25; fourPointSets(2, 0, 1) = 0.70;
583 fourPointSets(2, 1, 0) = 0.0001; fourPointSets(2, 1, 1) = 0.50;
586 fourPointSets(3, 0, 0) = 3.00; fourPointSets(3, 0, 1) = 1.00;
587 fourPointSets(3, 1, 0) = 3.50; fourPointSets(3, 1, 1) = 0.50;
589 CellTools::checkPointwiseInclusion(testFourSets, fourPointSets, triNodes, triangle_3);
591 for(
int cell = 0; cell < triNodes.dimension(0); cell++){
593 std::cout <<
" Testing point set inclusion for Triangle #" << cell <<
" with vertices \n"
594 <<
"\t(" << triNodes(cell, 0, 0) <<
", " << triNodes(cell, 0, 1) <<
")\n"
595 <<
"\t(" << triNodes(cell, 1, 0) <<
", " << triNodes(cell, 1, 1) <<
")\n"
596 <<
"\t(" << triNodes(cell, 1, 0) <<
", " << triNodes(cell, 1, 1) <<
")\n"
597 <<
" Results for physical point set indexed by the cell ordinal " << cell <<
" \n\n";
599 for(
int i1 = 0; i1 < fourPointSets.dimension(1); i1++) {
600 std::cout <<
" point(" << i1 <<
") = ("
601 << std::setw(13) << std::right << fourPointSets(cell, i1, 0) <<
","
602 << std::setw(13) << std::right << fourPointSets(cell, i1, 1) <<
") ";
603 if( testFourSets(cell, i1) ) {
604 std::cout <<
" is inside Triangle #" << cell <<
" \n";
607 std::cout <<
" is outside Triangle #" << cell <<
" \n";
610 if(cell < triNodes.dimension(0) - 1) {
611 std::cout <<
"-------------------------------------------------------------------------------\n";
621 <<
"===============================================================================\n"\
622 <<
"| EXAMPLE 5: Using point set inclusion test method |\n"\
623 <<
"===============================================================================\n";
625 std::cout <<
"\t Point set inclusion test for Triangle<6>: rank-2 array with four 2D point: \n";
627 if( CellTools::checkPointsetInclusion(fourPoints, tri6) ) {
628 std::cout <<
"\t - All points are inside the reference Triangle<6> cell. \n\n ";
631 std::cout <<
"\t - At least one point is not inside the reference Triangle<6> cell. \n\n";
634 std::cout <<
"\t Point set inclusion test for Hexahedron<27>: rank-3 array with six 3D point: \n";
636 if( CellTools::checkPointsetInclusion(six3DPoints, hex27) ) {
637 std::cout <<
"\t - All points are inside the reference Hexahedron<27> cell. \n\n ";
640 std::cout <<
"\t - At least one point is not inside the reference Hexahedron<27> cell. \n\n";
645 std::cout << std::setprecision(4) <<
"\n" \
646 <<
"===============================================================================\n"\
647 <<
"| EXAMPLE 6: mapping a single point set to physical cells with base topology |\n"\
648 <<
"===============================================================================\n";
652 refTriPoints(0,0) = 0.2; refTriPoints(0,1) = 0.0;
653 refTriPoints(1,0) = 0.4; refTriPoints(1,1) = 0.6;
654 refTriPoints(2,0) = 0.0; refTriPoints(2,1) = 0.8;
658 refTriPoints.dimension(0),
659 refTriPoints.dimension(1));
661 CellTools::mapToPhysicalFrame(physTriPoints, refTriPoints, triNodes, triangle_3);
663 for(
int cell = 0; cell < triNodes.dimension(0); cell++){
664 std::cout <<
"====== Triangle " << cell <<
" ====== \n";
665 for(
int pt = 0; pt < refTriPoints.dimension(0); pt++){
668 << std::setw(13) << std::right << refTriPoints(pt,0) <<
","
669 << std::setw(13) << std::right << refTriPoints(pt,1) <<
") -> "
671 << std::setw(13) << std::right << physTriPoints(cell, pt, 0) <<
","
672 << std::setw(13) << std::right << physTriPoints(cell, pt, 1) <<
") \n";
678 std::cout << std::setprecision(4) <<
"\n" \
679 <<
"===============================================================================\n"\
680 <<
"| EXAMPLE 7: mapping a single point set to physical cells with ext. topology |\n"\
681 <<
"===============================================================================\n";
696 tri6Nodes(0,0,0) = 1.0; tri6Nodes(0,0,1) = -0.5;
697 tri6Nodes(0,1,0) = 1.0; tri6Nodes(0,1,1) = 1.0;
698 tri6Nodes(0,2,0) = 0.0; tri6Nodes(0,2,1) = 0.0;
700 tri6Nodes(0,3,0) = 1.0; tri6Nodes(0,3,1) = 0.0;
701 tri6Nodes(0,4,0) = 0.5; tri6Nodes(0,4,1) = 0.25;
702 tri6Nodes(0,5,0) = 0.5; tri6Nodes(0,5,1) = -0.125;
706 refTri6Points(0,0) = 0.0; refTri6Points(0,1) = 0.0;
707 refTri6Points(1,0) = 1.0; refTri6Points(1,1) = 0.0;
708 refTri6Points(2,0) = 0.0; refTri6Points(2,1) = 1.0;
710 refTri6Points(3,0) = 0.5; refTri6Points(3,1) = 0.0;
711 refTri6Points(4,0) = 0.5; refTri6Points(4,1) = 0.5;
712 refTri6Points(5,0) = 0.0; refTri6Points(5,1) = 0.5;
714 refTri6Points(6,0) = 0.75; refTri6Points(6,1) = 0.0;
715 refTri6Points(7,0) = 0.25; refTri6Points(7,1) = 0.75;
716 refTri6Points(8,0) = 0.00; refTri6Points(8,1) = 0.25;
720 refTri6Points.dimension(0),
721 refTri6Points.dimension(1));
724 CellTopology triangle_6(shards::getCellTopologyData<Triangle<6> >() );
727 CellTools::mapToPhysicalFrame(physTri6Points, refTri6Points, tri6Nodes, triangle_6);
729 for(
int cell = 0; cell < tri6Nodes.dimension(0); cell++){
730 std::cout <<
"====== Triangle " << cell <<
" ====== \n";
731 for(
int pt = 0; pt < refTri6Points.dimension(0); pt++){
734 << std::setw(13) << std::right << refTri6Points(pt,0) <<
","
735 << std::setw(13) << std::right << refTri6Points(pt,1) <<
") -> "
737 << std::setw(13) << std::right << physTri6Points(cell, pt, 0) <<
","
738 << std::setw(13) << std::right << physTri6Points(cell, pt, 1) <<
") \n";
746 <<
"===============================================================================\n"\
747 <<
"| EXAMPLE 8: mapping a single physical point set to reference frame |\n"\
748 <<
"===============================================================================\n";
761 physPoints(0,0) = triNodes(3, 0, 0); physPoints(0,1) = triNodes(3, 0, 1) ;
762 physPoints(1,0) = triNodes(3, 1, 0); physPoints(1,1) = triNodes(3, 1, 1);
763 physPoints(2,0) = triNodes(3, 2, 0); physPoints(2,1) = triNodes(3, 2, 1);
766 physPoints(3,0) = 3.0; physPoints(3,1) = 1.0;
767 physPoints(4,0) = 2.5; physPoints(4,1) = 1.1;
772 CellTools::mapToReferenceFrame(preImages, physPoints, triNodes, triangle_3, whichCell );
774 std::cout <<
" Mapping from Triangle #"<< whichCell <<
" with vertices: \n"
775 <<
"\t(" << triNodes(whichCell, 0, 0) <<
", " << triNodes(whichCell, 0, 1) <<
")\n"
776 <<
"\t(" << triNodes(whichCell, 1, 0) <<
", " << triNodes(whichCell, 1, 1) <<
")\n"
777 <<
"\t(" << triNodes(whichCell, 1, 0) <<
", " << triNodes(whichCell, 1, 1) <<
")\n\n"
778 <<
" Physical points and their reference cell preimages: \n";
780 for(
int pt = 0; pt < physPoints.dimension(0); pt++){
782 <<
"(" << std::setw(13) << std::right << physPoints(pt,0) <<
","
783 << std::setw(13) << std::right << physPoints(pt,1) <<
") -> "
785 << std::setw(13) << std::right << preImages(pt, 0) <<
","
786 << std::setw(13) << std::right << preImages(pt, 1) <<
") \n";
792 CellTools::mapToPhysicalFrame(images, preImages, triNodes, triangle_3, whichCell);
794 std::cout <<
" Check: map preimages back to Triangle #3: \n";
795 for(
int pt = 0; pt < images.dimension(0); pt++){
797 <<
"(" << std::setw(13) << std::right << preImages(pt,0) <<
","
798 << std::setw(13) << std::right << preImages(pt,1) <<
") -> "
800 << std::setw(13) << std::right << images(pt, 0) <<
","
801 << std::setw(13) << std::right << images(pt, 1) <<
") \n";
807 <<
"===============================================================================\n"\
808 <<
"| EXAMPLE 9: mapping physical point sets on a cell workset to reference frame |\n"\
809 <<
"===============================================================================\n";
823 physPointSets(0,0,0) = 0.25; physPointSets(0,0,1) = 0.25;
824 physPointSets(0,1,0) = 0.50; physPointSets(0,1,1) = 0.50;
827 physPointSets(1,0,0) = 1.00; physPointSets(1,0,1) = 1.00;
828 physPointSets(1,1,0) = 1.25; physPointSets(1,1,1) = 1.75;
831 physPointSets(2,0,0) =-0.25; physPointSets(2,0,1) = 0.25;
832 physPointSets(2,1,0) =-0.50; physPointSets(2,1,1) = 0.50;
835 physPointSets(3,0,0) = 3.00; physPointSets(3,0,1) = 1.00;
836 physPointSets(3,1,0) = 2.00; physPointSets(3,1,1) = 1.00;
840 CellTools::mapToReferenceFrame(preImageSets, physPointSets, triNodes, triangle_3);
842 for(
int cell = 0; cell < triNodes.dimension(0); cell++){
843 std::cout <<
"====== Triangle " << cell <<
" ====== \n";
844 for(
int pt = 0; pt < physPointSets.dimension(1); pt++){
847 << std::setw(13) << std::right << physPointSets(cell, pt, 0) <<
","
848 << std::setw(13) << std::right << physPointSets(cell, pt, 1) <<
") -> "
850 << std::setw(13) << std::right << preImageSets(cell, pt, 0) <<
","
851 << std::setw(13) << std::right << preImageSets(cell, pt, 1) <<
") \n";
859 CellTools::mapToPhysicalFrame(postImageSets, preImageSets, triNodes, triangle_3);
861 std::cout <<
" Check: map preimages back to Triangles: \n";
862 for(
int cell = 0; cell < triNodes.dimension(0); cell++){
863 std::cout <<
"====== Triangle " << cell <<
" ====== \n";
864 for(
int pt = 0; pt < preImageSets.dimension(1); pt++){
867 << std::setw(13) << std::right << preImageSets(cell, pt, 0) <<
","
868 << std::setw(13) << std::right << preImageSets(cell, pt, 1) <<
") -> "
870 << std::setw(13) << std::right << postImageSets(cell, pt, 0) <<
","
871 << std::setw(13) << std::right << postImageSets(cell, pt, 1) <<
") \n";
Header file for utility class to provide multidimensional containers.