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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
|
<center><a href="UFCProblem.hh">Actual source code: UFCProblem.hh</a></center><br>
<html>
<head>
<title></title>
<meta name="generator" content="c2html 0.9.5">
<meta name="date" content="2010-04-08T19:55:25+00:00">
</head>
<body bgcolor="#FFFFFF">
<pre width="80"><a name="line1"> 1: </a><font color="#A020F0">#ifndef __UFCProblem</font>
<a name="line4"> 4: </a><font color="#B22222">/*</font>
<a name="line5"> 5: </a><font color="#B22222"> UFC Problem class for sieve; allows for UFC-assembled problems to be "bundled"</font>
<a name="line7"> 7: </a><font color="#B22222"> */</font>
<a name="line10"> 10: </a><font color="#A020F0">#include <Mesh.hh></font>
<a name="line11"> 11: </a><font color="#A020F0">#include <FEMProblem.hh></font>
<a name="line12"> 12: </a><font color="#A020F0">#include <ufc.h></font>
<a name="line14"> 14: </a>namespace ALE {
<a name="line15"> 15: </a> namespace Problem {
<a name="line17"> 17: </a> class UFCHook { //initialize all the data from the UFC forms so we don't need to keep redoing it
<a name="line18"> 18: </a><strong><font color="#FF0000"> public:</font></strong>
<a name="line20"> 20: </a> //the model <font color="#4169E1">for</font> this is of course b(u, v) = (l(v), f)... because it's UFC.
<a name="line21"> 21: </a> //<font color="#4169E1">if</font> we need to extend this make these into sets.
<a name="line23"> 23: </a><strong><font color="#FF0000"> ufc:</font></strong>:form * _lform;
<a name="line24"> 24: </a><strong><font color="#FF0000"> ufc:</font></strong>:form * _bform;
<a name="line26"> 26: </a> //finite elements
<a name="line28"> 28: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * _b_finite_element; //the thing upon which the cell integral is defined; however we want to crack it open <font color="#4169E1">for</font> discretizations
<a name="line29"> 29: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * _l_finite_element; //ditto
<a name="line31"> 31: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::finite_element *> _b_sub_finite_elements;
<a name="line32"> 32: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::finite_element *> _l_sub_finite_elements;
<a name="line33"> 33: </a>
<a name="line34"> 34: </a><strong><font color="#FF0000"> ufc:</font></strong>:shape _cell_shape;
<a name="line36"> 36: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * _cell; //assume, <font color="#4169E1">for</font> now, that the mesh has one cell type
<a name="line38"> 38: </a> //cell integrals
<a name="line40"> 40: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::cell_integral *> _b_cell_integrals;
<a name="line41"> 41: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::cell_integral *> _l_cell_integrals;
<a name="line43"> 43: </a> //interior facet integrals
<a name="line45"> 45: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::interior_facet_integral *> _b_interior_facet_integrals;
<a name="line46"> 46: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::interior_facet_integral *> _l_interior_facet_integrals;
<a name="line48"> 48: </a> //exterior facet integrals
<a name="line50"> 50: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::exterior_facet_integral *> _b_exterior_facet_integrals;
<a name="line51"> 51: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::exterior_facet_integral *> _l_exterior_facet_integrals;
<a name="line53"> 53: </a><strong><font color="#FF0000"> public:</font></strong>
<a name="line54"> 54: </a>
<a name="line55"> 55: </a> UFCHook(ufc::form * bform, ufc::form * lform) {
<a name="line57"> 57: </a> _bform = bform;
<a name="line58"> 58: </a> _lform = lform;
<a name="line59"> 59: </a>
<a name="line60"> 60: </a> //set up the cell, the finite_elements, the cell integrals
<a name="line61"> 61: </a>
<a name="line62"> 62: </a> //create the cell integrals
<a name="line63"> 63: </a> //_num_l_cell_integrals = lform->num_cell_integrals();
<a name="line64"> 64: </a> //_l_cell_integrals = new ufc::cell_integral *[_num_l_cell_integrals];
<a name="line65"> 65: </a> <font color="#4169E1">for</font> (unsigned int i = 0; i < lform->num_cell_integrals(); i++) {
<a name="line66"> 66: </a> _l_cell_integrals[i] = _lform->create_cell_integral(i);
<a name="line67"> 67: </a> }
<a name="line69"> 69: </a> <font color="#4169E1">if</font> (_l_cell_integrals.size() == 0) throw Exception(<font color="#666666">"No linear integrals in the form"</font>);
<a name="line70"> 70: </a>
<a name="line71"> 71: </a> //_num_b_cell_integrals = bform->num_cell_integrals();
<a name="line72"> 72: </a> //_b_cell_integrals = new ufc::cell_integral *[_num_l_cell_integrals];
<a name="line73"> 73: </a> <font color="#4169E1">for</font> (unsigned int i = 0; i < bform->num_cell_integrals(); i++) {
<a name="line74"> 74: </a> _b_cell_integrals[i] = bform->create_cell_integral(i);
<a name="line75"> 75: </a> }
<a name="line76"> 76: </a>
<a name="line77"> 77: </a> <font color="#4169E1">if</font> (_b_cell_integrals.size() == 0) {
<a name="line78"> 78: </a> throw Exception(<font color="#666666">"No bilinear integrals in the form"</font>);
<a name="line79"> 79: </a> }
<a name="line80"> 80: </a>
<a name="line81"> 81: </a> //create the finite elements <font color="#4169E1">for</font> the bform and lform; they should be the same I <font color="#4169E1">do</font> believe
<a name="line83"> 83: </a> _b_finite_element = _bform->create_finite_element(0); //the other appears to be <font color="#4169E1">for</font> quadrature
<a name="line85"> 85: </a> //_num_finite_elements = _bform->num_coefficients() + _bform->rank();//_bform->num_finite_elements();
<a name="line86"> 86: </a> //_finite_elements = new ufc::finite_element *[_num_finite_elements];
<a name="line88"> 88: </a> <font color="#4169E1">if</font> (_b_finite_element->num_sub_elements() > 1) <font color="#4169E1">for</font> (unsigned int i = 0; i < _b_finite_element->num_sub_elements(); i++) {
<a name="line89"> 89: </a> _b_sub_finite_elements[i] = _b_finite_element->create_sub_element(i);
<a name="line90"> 90: </a> }
<a name="line91"> 91: </a>
<a name="line92"> 92: </a> <font color="#B22222">/*</font>
<a name="line93"> 93: </a><font color="#B22222"> if (_b_sub_finite_elements.size() == 0) {</font>
<a name="line94"> 94: </a><font color="#B22222"> throw Exception("No finite elements in the form");</font>
<a name="line95"> 95: </a><font color="#B22222"> }</font>
<a name="line96"> 96: </a><font color="#B22222"> */</font>
<a name="line98"> 98: </a> _l_finite_element = _lform->create_finite_element(0);
<a name="line100">100: </a> //_num_coefficient_elements = _lform->num_coefficients() + _lform->rank();
<a name="line101">101: </a> //_coefficient_elements = new ufc::finite_element *[_num_coefficient_elements];
<a name="line102">102: </a> <font color="#4169E1">if</font> (_l_finite_element->num_sub_elements() > 1) <font color="#4169E1">for</font> (unsigned int i = 0; i < _l_finite_element->num_sub_elements(); i++) {
<a name="line103">103: </a> _l_sub_finite_elements[i] = lform->create_finite_element(i);
<a name="line104">104: </a> }
<a name="line106">106: </a> <font color="#B22222">/*</font>
<a name="line107">107: </a><font color="#B22222"> if (_l_sub_finite_elements.size() == 0) {</font>
<a name="line108">108: </a><font color="#B22222"> throw Exception("No coefficient elements in the form");</font>
<a name="line109">109: </a><font color="#B22222"> }</font>
<a name="line110">110: </a><font color="#B22222"> */</font>
<a name="line111">111: </a>
<a name="line112">112: </a> int dim, embedDim;
<a name="line113">113: </a> //derive these from the mesh and/or the finite element;
<a name="line114">114: </a> _cell = new ufc::cell;
<a name="line115">115: </a>
<a name="line116">116: </a>
<a name="line117">117: </a> _cell_shape = _l_finite_element->cell_shape();
<a name="line120">120: </a> <font color="#4169E1">if</font> (_cell_shape == ufc::interval) {
<a name="line121">121: </a> dim = 1;
<a name="line122">122: </a> embedDim = 1;
<a name="line123">123: </a> _cell->entity_indices = new unsigned int *[dim+1];
<a name="line124">124: </a> _cell->entity_indices[0] = new unsigned int[2];
<a name="line125">125: </a> _cell->entity_indices[1] = new unsigned int[1];
<a name="line126">126: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (_cell_shape == ufc::triangle) {
<a name="line127">127: </a> dim = 2;
<a name="line128">128: </a> embedDim = 2;
<a name="line129">129: </a> _cell->entity_indices = new unsigned int *[dim+1];
<a name="line130">130: </a> _cell->entity_indices[0] = new unsigned int[3];
<a name="line131">131: </a> _cell->entity_indices[1] = new unsigned int[3];
<a name="line132">132: </a> _cell->entity_indices[2] = new unsigned int[1];
<a name="line133">133: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (_cell_shape == ufc::tetrahedron) {
<a name="line134">134: </a> dim = 3;
<a name="line135">135: </a> embedDim = 3;
<a name="line136">136: </a> _cell->entity_indices = new unsigned int *[dim+1];
<a name="line137">137: </a> _cell->entity_indices[0] = new unsigned int[4];
<a name="line138">138: </a> _cell->entity_indices[1] = new unsigned int[6];
<a name="line139">139: </a> _cell->entity_indices[2] = new unsigned int[4];
<a name="line140">140: </a> _cell->entity_indices[3] = new unsigned int[1];
<a name="line141">141: </a> } <font color="#4169E1">else</font> {
<a name="line142">142: </a> throw Exception(<font color="#666666">"Unknown cell shape"</font>);
<a name="line143">143: </a> }
<a name="line144">144: </a> //create the cell
<a name="line145">145: </a> _cell->topological_dimension = dim;
<a name="line146">146: </a> _cell->geometric_dimension = embedDim;
<a name="line147">147: </a> double * tmpCoords = new double[(dim+1)*embedDim];
<a name="line148">148: </a> _cell->coordinates = new double *[dim+1];
<a name="line149">149: </a> <font color="#4169E1">for</font> (int i = 0; i < dim+1; i++) {
<a name="line150">150: </a> _cell->coordinates[i] = &tmpCoords[i*embedDim];
<a name="line151">151: </a> }
<a name="line152">152: </a>
<a name="line153">153: </a> }
<a name="line154">154: </a>
<a name="line155">155: </a> ~UFCHook() {
<a name="line156">156: </a> //remove all this stuff
<a name="line157">157: </a> delete _lform;
<a name="line158">158: </a> delete _bform;
<a name="line159">159: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::cell_integral *>::iterator i_iter = _l_cell_integrals.begin();
<a name="line160">160: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::cell_integral *>::iterator i_iter_end = _l_cell_integrals.end();
<a name="line161">161: </a> <font color="#4169E1">while</font> (i_iter != i_iter_end) {
<a name="line162">162: </a> delete i_iter->second;
<a name="line163">163: </a> i_iter++;
<a name="line164">164: </a> }
<a name="line165">165: </a> i_iter = _b_cell_integrals.begin();
<a name="line166">166: </a> i_iter_end = _b_cell_integrals.end();
<a name="line167">167: </a> <font color="#4169E1">while</font> (i_iter != i_iter_end) {
<a name="line168">168: </a> delete i_iter->second;
<a name="line169">169: </a> i_iter++;
<a name="line170">170: </a> }
<a name="line171">171: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::finite_element *>::iterator f_iter = _l_sub_finite_elements.begin();
<a name="line172">172: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, ufc::finite_element *>::iterator f_iter_end = _l_sub_finite_elements.end();
<a name="line173">173: </a> <font color="#4169E1">while</font> (f_iter != f_iter_end) {
<a name="line174">174: </a> delete f_iter->second;
<a name="line175">175: </a> f_iter++;
<a name="line176">176: </a> }
<a name="line177">177: </a> delete _cell->coordinates[0];
<a name="line178">178: </a> delete _cell->coordinates;
<a name="line179">179: </a> }
<a name="line181">181: </a> //accessors
<a name="line182">182: </a>
<a name="line184">184: </a> void setCell(Obj<PETSC_MESH_TYPE> m, PETSC_MESH_TYPE::point_type c) {
<a name="line185">185: </a> //setup the cell object such that it contains the mesh cell given
<a name="line186">186: </a>
<a name="line187">187: </a> const Obj<PETSC_MESH_TYPE::sieve_type> s = m->getSieve();
<a name="line188">188: </a> Obj<PETSC_MESH_TYPE::real_section_type> coordinates = m->getRealSection(<font color="#666666">"coordinates"</font>);
<a name="line189">189: </a> int dim = m->getDimension();
<a name="line190">190: </a> <font color="#4169E1">if</font> ((int)_cell->topological_dimension != m->getDimension() - m->height(c)) throw ALE::Exception(<font color="#666666">"Wrong element dimension for this UFC form"</font>);
<a name="line191">191: </a> //int depth = m->depth();
<a name="line192">192: </a> //the entity indices should be FIXED because we don't care to use any of the DoFMap stuff
<a name="line193">193: </a><strong><font color="#FF0000"> ISieveVisitor:</font></strong>:PointRetriever<PETSC_MESH_TYPE::sieve_type> pV((int) pow(m->getSieve()->getMaxConeSize(), m->depth())+1, true);
<a name="line194">194: </a> ISieveTraversal<PETSC_MESH_TYPE::sieve_type>::orientedClosure(*m->getSieve(), c, pV);
<a name="line196">196: </a> const PETSC_MESH_TYPE::point_type * oPoints = pV.getPoints();
<a name="line197">197: </a> int num_oPoints = pV.getSize();
<a name="line198">198: </a> int vertex_index = 0;
<a name="line199">199: </a> <font color="#4169E1">for</font> (int t = 0; t < num_oPoints; t++) {
<a name="line200">200: </a> <font color="#4169E1">if</font> (m->depth(oPoints[t]) == 0) {
<a name="line201">201: </a> // _cell->entity_indices[0][vertex_index] = oPoints[t];
<a name="line202">202: </a> const double * tmpcoords = coordinates->restrictPoint(oPoints[t]);
<a name="line203">203: </a> <font color="#4169E1">for</font> (int i = 0; i < dim; i++) {
<a name="line204">204: </a> _cell->coordinates[vertex_index][i] = tmpcoords[i];
<a name="line205">205: </a> }
<a name="line206">206: </a> vertex_index++;
<a name="line207">207: </a> }
<a name="line208">208: </a> }
<a name="line209">209: </a> }
<a name="line210">210: </a> };
<a name="line212">212: </a><font color="#A020F0">#if 0</font>
<a name="line214">214: </a> class UFCCell : GeneralCell {
<a name="line215">215: </a><strong><font color="#FF0000"> private:</font></strong>
<a name="line216">216: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * _cell; //the UFC cell.
<a name="line217">217: </a><strong><font color="#FF0000"> public:</font></strong>
<a name="line218">218: </a> UFCCell (ufc::shape shape, int embed_dimension) : GeneralCell() {
<a name="line219">219: </a> _embedded_dimension = embed_dimension;
<a name="line220">220: </a> <font color="#4169E1">if</font> (shape == ufc::interval) {
<a name="line221">221: </a> //allocate coordinates
<a name="line222">222: </a> _num_vertices = 2;
<a name="line223">223: </a> _coordinates = new double [_num_vertices*_embedded_dimension];
<a name="line224">224: </a> //setup the closure reorder
<a name="line225">225: </a> //setup the ufc::cell
<a name="line226">226: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (shape == ufc::triangle) {
<a name="line227">227: </a> //allocate coordinates
<a name="line228">228: </a> _num_vertices = 3;
<a name="line229">229: </a> _coordinates = new double [_num_vertices*_embedded_dimension];
<a name="line230">230: </a> //setup the closure reorder
<a name="line231">231: </a> //setup the ufc::cell
<a name="line232">232: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (shape == ufc::tetrahedron) {
<a name="line233">233: </a> //allocate coordinates
<a name="line234">234: </a> _num_vertices = 4;
<a name="line235">235: </a> _coordinates = new double [_num_vertices*_embedded_dimension];
<a name="line236">236: </a> //setup the closure reorder
<a name="line237">237: </a> //setup the ufc::cell
<a name="line238">238: </a> } <font color="#4169E1">else</font> throw Exception(<font color="#666666">"UFCCell: Unsupported Shape"</font>);
<a name="line239">239: </a> }
<a name="line240">240: </a> };
<a name="line241">241: </a>
<a name="line242">242: </a><font color="#A020F0">#endif</font>
<a name="line244">244: </a> class UFCBoundaryCondition : public GeneralBoundaryCondition {
<a name="line245">245: </a><strong><font color="#FF0000"> private:</font></strong>
<a name="line246">246: </a> //exact function
<a name="line248">248: </a><strong><font color="#FF0000"> ufc:</font></strong>:function * _function; //this will be evaluated to set the conditions.
<a name="line249">249: </a><strong><font color="#FF0000"> ufc:</font></strong>:function * _exactSol; //this will be evaluated in the <font color="#4169E1">case</font> that there is an analytic solution to the associated problem.
<a name="line250">250: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * _finite_element; //we have to evaluate both the function and the exactsol at some point
<a name="line251">251: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * _cell; //ugh
<a name="line252">252: </a> int * _closure2data; //map of LOCAL DISCRETIZATION closure dof indices to data dof indices; used <font color="#4169E1">for</font> evaluation
<a name="line255">255: </a><strong><font color="#FF0000"> public:</font></strong>
<a name="line256">256: </a> UFCBoundaryCondition(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, int debug = 0) : GeneralBoundaryCondition(comm, debug) {
<a name="line257">257: </a> _function = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line258">258: </a> _exactSol = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line259">259: </a> }
<a name="line261">261: </a> UFCBoundaryCondition(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, ufc::function * function, ufc::function * exactsol, ufc::finite_element * element, ufc::cell * cell, const std::string& name, const int marker, int debug = 0) : GeneralBoundaryCondition(comm, debug){
<a name="line262">262: </a> _function = function;
<a name="line263">263: </a> _exactSol = exactsol;
<a name="line264">264: </a> this->setFiniteElement(element);
<a name="line265">265: </a> _cell = cell;
<a name="line266">266: </a> this->setLabelName(name);
<a name="line267">267: </a> this->setMarker(marker);
<a name="line268">268: </a> }
<a name="line270">270: </a> void setFiniteElement(ufc::finite_element * finite_element) {
<a name="line271">271: </a> _finite_element = finite_element;
<a name="line272">272: </a> }
<a name="line273">273: </a>
<a name="line274">274: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * getFiniteElement() {
<a name="line275">275: </a> <font color="#4169E1">return</font> _finite_element;
<a name="line276">276: </a> }
<a name="line277">277: </a>
<a name="line278">278: </a> void setCell(ufc::cell * cell) {
<a name="line279">279: </a> _cell = cell;
<a name="line280">280: </a> }
<a name="line282">282: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * getCell() {
<a name="line283">283: </a> <font color="#4169E1">return</font> _cell;
<a name="line284">284: </a> }
<a name="line286">286: </a> void setFunction(ufc::function * function) {
<a name="line287">287: </a> _function = function;
<a name="line288">288: </a> }
<a name="line290">290: </a><strong><font color="#FF0000"> ufc:</font></strong>:function * getFunction() {
<a name="line291">291: </a> <font color="#4169E1">return</font> _function;
<a name="line292">292: </a> }
<a name="line294">294: </a> //SHOULD be the same as the closure reorder <font color="#4169E1">for</font> the overlying discretization. This is just <font color="#4169E1">for</font> library interface of course.
<a name="line296">296: </a> virtual void setReorder(int * reorder) {
<a name="line297">297: </a> this->_closure2data = reorder;
<a name="line298">298: </a> }
<a name="line300">300: </a> virtual const int * getReorder() {
<a name="line301">301: </a> <font color="#4169E1">return</font> this->_closure2data;
<a name="line302">302: </a> }
<a name="line305">305: </a> //yeargh! <font color="#4169E1">do</font> we ever use evaluate explicitly?
<a name="line306">306: </a> virtual double integrateDual(unsigned int dof) {
<a name="line307">307: </a> int ufc_dof;
<a name="line308">308: </a> ufc_dof = this->getReorder()[dof];
<a name="line309">309: </a> //just evaluate the function using the coordinates; assume the order doesn't get that screwed up
<a name="line310">310: </a> <font color="#4169E1">return</font> this->_finite_element->evaluate_dof(ufc_dof, *_function, *_cell);
<a name="line311">311: </a> }
<a name="line312">312: </a> };
<a name="line313">313: </a>
<a name="line314">314: </a> class UFCDiscretization : public GeneralDiscretization {
<a name="line315">315: </a> //implementation of the discretization class that provides UFC hooks.
<a name="line316">316: </a><strong><font color="#FF0000"> private:</font></strong>
<a name="line317">317: </a> //Each form will have the finite element -- not true; you have to associate by which part of the SPACE the
<a name="line318">318: </a> //integral exists over. So, we must assign each integral to the appropriate space (as we might have TWO integrals
<a name="line319">319: </a> //over say, the interior and then a boundary integral NOT TRUE AGAIN! all the integrals have to happen over the
<a name="line320">320: </a> //overall form; they must be done a class up. This should just be used to segment the space
<a name="line321">321: </a> //
<a name="line322">322: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * _cell;
<a name="line323">323: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * _finite_element; //this will typically be a subelement.
<a name="line324">324: </a><strong><font color="#FF0000"> ufc:</font></strong>:function * _rhs_function; //TODO: generalize this further
<a name="line325">325: </a>
<a name="line326">326: </a><strong><font color="#FF0000"> public:</font></strong>
<a name="line327">327: </a> UFCDiscretization(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, int debug = 1) : GeneralDiscretization(comm, debug) {
<a name="line328">328: </a> }
<a name="line330">330: </a> UFCDiscretization(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, ufc::finite_element * element, ufc::cell * cell, int debug = 1) : GeneralDiscretization(comm, debug){
<a name="line331">331: </a> _finite_element = element;
<a name="line332">332: </a> _cell = cell;
<a name="line333">333: </a> }
<a name="line335">335: </a> ~UFCDiscretization() {
<a name="line336">336: </a> }
<a name="line338">338: </a> virtual void createReorder() {
<a name="line339">339: </a>
<a name="line340">340: </a> //create the forward and backward maps to and from UFC data layout to closure data layout.
<a name="line341">341: </a> //<font color="#4169E1">do</font> this <font color="#4169E1">case</font>-by-<font color="#4169E1">case</font> with info from the discretization
<a name="line342">342: </a>
<a name="line343">343: </a> int * reorder = new int[this->size()];
<a name="line344">344: </a><strong><font color="#FF0000"> std:</font></strong>:map<int, int> closure_offsets;
<a name="line345">345: </a> int offset = 0;
<a name="line346">346: </a> <font color="#4169E1">if</font> (this->getFiniteElement()->cell_shape() == ufc::interval) {
<a name="line347">347: </a> //find the indices corresponding to every point in the topology and assume they're ordered right; <font color="#4169E1">if</font> not then we redo this later.
<a name="line348">348: </a> closure_offsets[0] = 0;
<a name="line349">349: </a> offset += this->getNumDof(1);
<a name="line350">350: </a> closure_offsets[1] = offset;
<a name="line351">351: </a> offset += this->getNumDof(0);
<a name="line352">352: </a> closure_offsets[2] = offset;
<a name="line353">353: </a> offset += this->getNumDof(0);
<a name="line354">354: </a> //we know the reorder; <font color="#4169E1">do</font> it!
<a name="line355">355: </a> int offset = 0;
<a name="line356">356: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[1] + i] = offset;
<a name="line357">357: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[2] + i] = offset;
<a name="line358">358: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[0] + i] = offset;
<a name="line359">359: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (this->getFiniteElement()->cell_shape() == ufc::triangle) {
<a name="line360">360: </a> closure_offsets[0] = 0;
<a name="line361">361: </a> offset += this->getNumDof(2);
<a name="line362">362: </a> closure_offsets[1] = offset;
<a name="line363">363: </a> offset += this->getNumDof(1);
<a name="line364">364: </a> closure_offsets[2] = offset;
<a name="line365">365: </a> offset += this->getNumDof(1);
<a name="line366">366: </a> closure_offsets[3] = offset;
<a name="line367">367: </a> offset += this->getNumDof(1);
<a name="line368">368: </a> closure_offsets[4] = offset;
<a name="line369">369: </a> offset += this->getNumDof(0);
<a name="line370">370: </a> closure_offsets[5] = offset;
<a name="line371">371: </a> offset += this->getNumDof(0);
<a name="line372">372: </a> closure_offsets[6] = offset;
<a name="line373">373: </a> offset += this->getNumDof(0);
<a name="line374">374: </a> //we know the reorder; <font color="#4169E1">do</font> it!
<a name="line375">375: </a> int offset = 0;
<a name="line376">376: </a> //this order is checked -- and appears to be right
<a name="line377">377: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[4] + i] = offset;
<a name="line378">378: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[5] + i] = offset;
<a name="line379">379: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[6] + i] = offset;
<a name="line380">380: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[2] + i] = offset;
<a name="line381">381: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[3] + i] = offset;
<a name="line382">382: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[1] + i] = offset;
<a name="line383">383: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(2); i++, offset++) reorder[closure_offsets[0] + i] = offset;
<a name="line384">384: </a> //TET!
<a name="line385">385: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (this->getFiniteElement()->cell_shape() == ufc::tetrahedron) {
<a name="line386">386: </a> closure_offsets[0] = 0;
<a name="line387">387: </a> offset += this->getNumDof(3);
<a name="line388">388: </a> closure_offsets[1] = offset;
<a name="line389">389: </a> offset += this->getNumDof(2);
<a name="line390">390: </a> closure_offsets[2] = offset;
<a name="line391">391: </a> offset += this->getNumDof(2);
<a name="line392">392: </a> closure_offsets[3] = offset;
<a name="line393">393: </a> offset += this->getNumDof(2);
<a name="line394">394: </a> closure_offsets[4] = offset;
<a name="line395">395: </a> offset += this->getNumDof(2);
<a name="line396">396: </a> closure_offsets[5] = offset;
<a name="line397">397: </a> offset += this->getNumDof(1);
<a name="line398">398: </a> closure_offsets[6] = offset;
<a name="line399">399: </a> offset += this->getNumDof(1);
<a name="line400">400: </a> closure_offsets[7] = offset;
<a name="line401">401: </a> offset += this->getNumDof(1);
<a name="line402">402: </a> closure_offsets[8] = offset;
<a name="line403">403: </a> offset += this->getNumDof(1);
<a name="line404">404: </a> closure_offsets[9] = offset;
<a name="line405">405: </a> offset += this->getNumDof(1);
<a name="line406">406: </a> closure_offsets[10] = offset;
<a name="line407">407: </a> offset += this->getNumDof(1);
<a name="line408">408: </a> closure_offsets[11] = offset;
<a name="line409">409: </a> offset += this->getNumDof(0);
<a name="line410">410: </a> closure_offsets[12] = offset;
<a name="line411">411: </a> offset += this->getNumDof(0);
<a name="line412">412: </a> closure_offsets[13] = offset;
<a name="line413">413: </a> offset += this->getNumDof(0);
<a name="line414">414: </a> closure_offsets[14] = offset;
<a name="line415">415: </a> offset += this->getNumDof(0);
<a name="line416">416: </a> //we know the reorder; <font color="#4169E1">do</font> it!
<a name="line417">417: </a> int offset = 0;
<a name="line418">418: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[11] + i] = offset;
<a name="line419">419: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[12] + i] = offset;
<a name="line420">420: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[13] + i] = offset;
<a name="line421">421: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(0); i++, offset++) reorder[closure_offsets[14] + i] = offset;
<a name="line422">422: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[10] + i] = offset;
<a name="line423">423: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[9] + i] = offset;
<a name="line424">424: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[6] + i] = offset;
<a name="line425">425: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[8] + i] = offset;
<a name="line426">426: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[7] + i] = offset;
<a name="line427">427: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(1); i++, offset++) reorder[closure_offsets[5] + i] = offset;
<a name="line428">428: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(2); i++, offset++) reorder[closure_offsets[4] + i] = offset;
<a name="line429">429: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(2); i++, offset++) reorder[closure_offsets[3] + i] = offset;
<a name="line430">430: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(2); i++, offset++) reorder[closure_offsets[2] + i] = offset;
<a name="line431">431: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(2); i++, offset++) reorder[closure_offsets[1] + i] = offset;
<a name="line432">432: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getNumDof(3); i++, offset++) reorder[closure_offsets[0] + i] = offset;
<a name="line433">433: </a> } <font color="#4169E1">else</font> {
<a name="line434">434: </a> throw Exception(<font color="#666666">"UFCDiscretization->createReordering(): unsupported cell geometry"</font>);
<a name="line435">435: </a> }
<a name="line436">436: </a> this->setReorder(reorder);
<a name="line437">437: </a> //set this as the reorder of all boundary conditions involved here.
<a name="line438">438: </a> Obj<names_type> bcs = this->getBoundaryConditions();
<a name="line439">439: </a><strong><font color="#FF0000"> names_type:</font></strong>:iterator bc_iter = bcs->begin();
<a name="line440">440: </a><strong><font color="#FF0000"> names_type:</font></strong>:iterator bc_iter_end = bcs->end();
<a name="line441">441: </a> <font color="#4169E1">while</font> (bc_iter != bc_iter_end) {
<a name="line442">442: </a> Obj<GeneralBoundaryCondition> bc = this->getBoundaryCondition(*bc_iter);
<a name="line443">443: </a> bc->setReorder(reorder);
<a name="line444">444: </a> bc_iter++;
<a name="line445">445: </a> }
<a name="line446">446: </a> }
<a name="line447">447: </a>
<a name="line448">448: </a> virtual void setReorder(const int * _reordering) {
<a name="line449">449: </a> _closure2data = _reordering;
<a name="line450">450: </a> }
<a name="line452">452: </a> virtual const int * getReorder() {
<a name="line453">453: </a> <font color="#4169E1">return</font> _closure2data;
<a name="line454">454: </a> }
<a name="line455">455: </a>
<a name="line456">456: </a> void setRHSFunction(ufc::function * function) {
<a name="line457">457: </a> _rhs_function = function;
<a name="line458">458: </a> }
<a name="line460">460: </a><strong><font color="#FF0000"> ufc:</font></strong>:function * getRHSFunction() {
<a name="line461">461: </a> <font color="#4169E1">return</font> _rhs_function;
<a name="line462">462: </a> }
<a name="line464">464: </a> virtual double evaluateRHS(int dof) {
<a name="line466">466: </a> //our notion of a degree of freedom in this <font color="#4169E1">case</font> is a little different from the one used by UFC; they have the whole dimension of the vector space as
<a name="line467">467: </a> //one DOF with multiple coefficients; <font color="#4169E1">for</font> the sake of being able to loop independent of the vector space here we split it up.
<a name="line469">469: </a> int ufc_dof;
<a name="line470">470: </a> <font color="#4169E1">if</font> (_cell == <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>) throw Exception(<font color="#666666">"UFCBoundaryCondition->integrateDual: cell is not initialized"</font>);
<a name="line471">471: </a> //TODO reordering
<a name="line472">472: </a> ufc_dof = this->getReorder()[dof];
<a name="line473">473: </a> //<font color="#4169E1">switch</font> the order
<a name="line475">475: </a> //TODO: reorder based upon the cell attributes -- <font color="#4169E1">switch</font> the dof_index to be the screwy indices as used by the
<a name="line476">476: </a> //cells... this requires knowledge of the dofs per dim here
<a name="line478">478: </a> //just evaluate the function using the coordinates; assume the order doesn't get that screwed up
<a name="line480">480: </a> <font color="#4169E1">return</font> _finite_element->evaluate_dof(ufc_dof, *_rhs_function, *_cell);
<a name="line481">481: </a> }
<a name="line483">483: </a> int size() {
<a name="line484">484: </a> <font color="#4169E1">return</font> _finite_element->space_dimension();
<a name="line485">485: </a> }
<a name="line487">487: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * getFiniteElement() {<font color="#4169E1">return</font> _finite_element;};
<a name="line488">488: </a> void setFiniteElement(ufc::finite_element * element) {_finite_element = element;};
<a name="line489">489: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * getCell() {<font color="#4169E1">return</font> _cell;};
<a name="line490">490: </a> void setCell(ufc::cell * cell) {_cell = cell;};
<a name="line492">492: </a> };
<a name="line494">494: </a> class UFCCellIntegral : public GeneralIntegral {
<a name="line495">495: </a><strong><font color="#FF0000"> private:</font></strong>
<a name="line496">496: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell_integral * _integral;
<a name="line497">497: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * _cell;
<a name="line498">498: </a> const double ** _coefficients;
<a name="line499">499: </a> double * _tmp_tensor; //allows <font color="#4169E1">for</font> us to reorder on the fly.
<a name="line500">500: </a> double * _tmp_coefficients;
<a name="line501">501: </a><strong><font color="#FF0000"> public:</font></strong>
<a name="line502">502: </a> UFCCellIntegral(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, int debug = 1) : GeneralIntegral(comm, debug) {
<a name="line503">503: </a> this->_tmp_tensor = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line504">504: </a> this->_tmp_coefficients = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line505">505: </a> this->_integral = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line506">506: </a> this->_cell = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line507">507: </a> this->_coefficients = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line508">508: </a> }
<a name="line510">510: </a> UFCCellIntegral(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, ufc::cell_integral * integral, ufc::cell * cell, name_type name, int label, int rank, int dimension, int ncoefficients = 0, int debug = 0) : GeneralIntegral(comm, name, label, ncoefficients, debug){
<a name="line511">511: </a> this->_integral = integral;
<a name="line512">512: </a> this->_cell = cell;
<a name="line513">513: </a> this->setTensorRank(rank);
<a name="line514">514: </a> this->setSpaceDimension(dimension);
<a name="line515">515: </a> this->setNumCoefficients(ncoefficients);
<a name="line516">516: </a> <font color="#4169E1">if</font> (rank == 1) {
<a name="line517">517: </a> this->_tmp_tensor = new double[dimension];
<a name="line518">518: </a> } <font color="#4169E1">else</font> <font color="#4169E1">if</font> (rank == 2) {
<a name="line519">519: </a> this->_tmp_tensor = new double[dimension*dimension];
<a name="line520">520: </a> } <font color="#4169E1">else</font> {
<a name="line521">521: </a> throw Exception(<font color="#666666">"UFCCellIntegral::UFCCellIntegral(): unsupported tensor rank"</font>);
<a name="line522">522: </a> }
<a name="line523">523: </a> <font color="#4169E1">if</font> (ncoefficients) {
<a name="line524">524: </a> this->_tmp_coefficients = new double[dimension*ncoefficients];
<a name="line525">525: </a> this->_coefficients = new const double*[ncoefficients];
<a name="line526">526: </a> } <font color="#4169E1">else</font> this->_coefficients = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line527">527: </a> }
<a name="line529">529: </a> virtual ~UFCCellIntegral() {
<a name="line530">530: </a> delete _coefficients;
<a name="line531">531: </a> <font color="#4169E1">if</font> (_tmp_tensor) delete _tmp_tensor;
<a name="line532">532: </a> <font color="#4169E1">if</font> (_tmp_coefficients) delete _tmp_coefficients;
<a name="line533">533: </a> };
<a name="line535">535: </a> virtual ufc::cell * getCell() {
<a name="line536">536: </a> <font color="#4169E1">return</font> _cell;
<a name="line537">537: </a> }
<a name="line539">539: </a> virtual void setCell(ufc::cell * cell) {
<a name="line540">540: </a> _cell = cell;
<a name="line541">541: </a> }
<a name="line543">543: </a> virtual void setIntegral(ufc::cell_integral * integral) {
<a name="line544">544: </a> _integral = integral;
<a name="line545">545: </a> }
<a name="line546">546: </a>
<a name="line547">547: </a> virtual ufc::cell_integral * getIntegral () {
<a name="line548">548: </a> <font color="#4169E1">return</font> _integral;
<a name="line549">549: </a> }
<a name="line552">552: </a> //there will eventually be some reordering occuring here, but <font color="#4169E1">for</font> now just assume we've done the right thing.
<a name="line553">553: </a> virtual void tabulateTensor(double * tensor, const double * coefficients = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>) {
<a name="line554">554: </a> //just run the frickin' tabulate_tensor routine from the form on what gets spit out by restrictClosure right now; rebuild or reorder later.
<a name="line555">555: </a> //the coefficients have come in in
<a name="line556">556: </a> <font color="#4169E1">if</font> (this->getNumCoefficients()) {
<a name="line557">557: </a> <font color="#4169E1">for</font> (int c = 0; c < this->getNumCoefficients(); c++) {
<a name="line558">558: </a> this->_coefficients[c] = &_tmp_coefficients[c*this->getNumCoefficients()];
<a name="line559">559: </a> <font color="#4169E1">for</font> (int i = 0; i < this->getSpaceDimension(); i++) {
<a name="line560">560: </a> //reorder the coefficients into the _tmp_coefficients array
<a name="line561">561: </a> _tmp_coefficients[c*this->getNumCoefficients() + this->getReorder()[i]] = coefficients[i*this->getNumCoefficients() + c]; //may be wrong.
<a name="line562">562: </a> }
<a name="line563">563: </a> }
<a name="line564">564: </a> }
<a name="line566">566: </a> //the coefficients should already be reordered from the closure order to the normal order based upon the set
<a name="line567">567: </a> _integral->tabulate_tensor(_tmp_tensor, _coefficients, *_cell);
<a name="line568">568: </a> //reorder the tabulated tensor
<a name="line569">569: </a> <font color="#4169E1">if</font> (this->getTensorRank() == 1) {
<a name="line570">570: </a> <font color="#4169E1">for</font> (int f = 0; f < this->getSpaceDimension(); f++) {
<a name="line571">571: </a> tensor[f] = _tmp_tensor[this->getReorder()[f]];
<a name="line572">572: </a> }
<a name="line573">573: </a> }<font color="#4169E1">else</font> <font color="#4169E1">if</font> (this->getTensorRank() == 2) {
<a name="line574">574: </a> <font color="#4169E1">for</font> (int f = 0; f < this->getSpaceDimension(); f++) {
<a name="line575">575: </a> <font color="#4169E1">for</font> (int g = 0; g < this->getSpaceDimension(); g++) {
<a name="line576">576: </a> tensor[f*this->getSpaceDimension()+g] = _tmp_tensor[this->getReorder()[f]*this->getSpaceDimension()+this->getReorder()[g]]; //this should reorder it right.
<a name="line577">577: </a> }
<a name="line578">578: </a> }
<a name="line579">579: </a> }
<a name="line580">580: </a> }
<a name="line581">581: </a> };
<a name="line583">583: </a> //TODO: interior; exterior integral forms; these will have their own reordering notion.
<a name="line585">585: </a> class UFCFormSubProblem : public GenericFormSubProblem {
<a name="line586">586: </a>
<a name="line587">587: </a> //Data and helper functions:
<a name="line589">589: </a><strong><font color="#FF0000"> private:</font></strong>
<a name="line591">591: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * _cell; //we'll have to pass this on to all the children of this class;
<a name="line592">592: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * _full_finite_element; //the big one with all unknowns (even mixed) described. all integrals are assumed to be defined on it
<a name="line594">594: </a><strong><font color="#FF0000"> public:</font></strong>
<a name="line596">596: </a> UFCFormSubProblem(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, int debug = 0) : GenericFormSubProblem(comm, debug) {
<a name="line597">597: </a> //yeah
<a name="line598">598: </a> _cell = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line599">599: </a> _full_finite_element = <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>;
<a name="line600">600: </a> }
<a name="line602">602: </a> UFCFormSubProblem(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, ufc::cell * cell, ufc::finite_element * finite_element, int debug = 0) : GenericFormSubProblem(comm, debug) {
<a name="line603">603: </a> _cell = cell; //yeargh!
<a name="line604">604: </a> _full_finite_element = finite_element;
<a name="line605">605: </a> }
<a name="line606">606: </a>
<a name="line607">607: </a> UFCFormSubProblem(<A href="../../docs/manualpages/Sys/MPI_Comm.html#MPI_Comm">MPI_Comm</A> comm, ufc::form * b_form, ufc::form * l_form, int debug = 0) : GenericFormSubProblem(comm, debug){
<a name="line608">608: </a> //set up the discretizations, integrals, and other things; discretization-level things like boundary conditions must be set separately of course.
<a name="line609">609: </a> //set the main finite element, the sub-elements, and
<a name="line610">610: </a> }
<a name="line612">612: </a><strong><font color="#FF0000"> ufc:</font></strong>:cell * getCell() {
<a name="line613">613: </a> <font color="#4169E1">return</font> _cell;
<a name="line614">614: </a> }
<a name="line616">616: </a><strong><font color="#FF0000"> ufc:</font></strong>:finite_element * getFiniteElement() {
<a name="line617">617: </a> <font color="#4169E1">return</font> _full_finite_element;
<a name="line618">618: </a> }
<a name="line620">620: </a> virtual int localSpaceDimension() {
<a name="line621">621: </a> <font color="#4169E1">return</font> _full_finite_element->space_dimension();
<a name="line622">622: </a> }
<a name="line624">624: </a> virtual void createReorder () {
<a name="line625">625: </a> <font color="#B22222">/*</font>
<a name="line626">626: </a><font color="#B22222"> GOAL: keep all interface-level things (in the other file) in *closure* order.</font>
<a name="line627">627: </a><font color="#B22222"> </font>
<a name="line629">629: </a><font color="#B22222"> The UFC ordering is assumed to go: </font>
<a name="line630">630: </a><font color="#B22222"> 1. discretization 1 entry 0 reordered per-cell like UFC</font>
<a name="line631">631: </a><font color="#B22222"> discretization 1 entry 1 ...</font>
<a name="line632">632: </a><font color="#B22222"> 2. discretization 2 reordered per-cell like UFC</font>
<a name="line633">633: </a><font color="#B22222"> ... etc</font>
<a name="line634">634: </a><font color="#B22222"> </font>
<a name="line635">635: </a><font color="#B22222"> So, we first pull apart each discretization and reorder (based upon the indices of that discretization and the rank of the form, then based upon the discretization</font>
<a name="line637">637: </a><font color="#B22222"> Then pass the overall reorder to each integral to make all of this go smoothly.</font>
<a name="line639">639: </a><font color="#B22222"> */</font>
<a name="line640">640: </a>
<a name="line641">641: </a> int * reorder = new int[this->localSpaceDimension()];
<a name="line642">642: </a> //<A href="../../docs/manualpages/Sys/PetscPrintf.html#PetscPrintf">PetscPrintf</A>(<A href="../../docs/manualpages/Sys/PETSC_COMM_WORLD.html#PETSC_COMM_WORLD">PETSC_COMM_WORLD</A>, <font color="#666666">"starting the reorder calculation\n"</font>);
<a name="line643">643: </a> //loop over discretizations, creating the local reorders
<a name="line644">644: </a> Obj<names_type> discs = this->getDiscretizations();
<a name="line645">645: </a> int offset = 0;
<a name="line646">646: </a> <font color="#4169E1">for</font> (names_type::const_iterator d_iter = discs->begin(); d_iter != discs->end(); d_iter++) {
<a name="line647">647: </a> const Obj<GeneralDiscretization> disc = this->getDiscretization(*d_iter);
<a name="line648">648: </a> disc->createReorder();
<a name="line649">649: </a> const int * disc_indices = disc->getIndices();
<a name="line650">650: </a> const int * disc_reorder = disc->getReorder();
<a name="line651">651: </a> int disc_size = disc->size();
<a name="line652">652: </a> //<A href="../../docs/manualpages/Sys/PetscPrintf.html#PetscPrintf">PetscPrintf</A>(<A href="../../docs/manualpages/Sys/PETSC_COMM_WORLD.html#PETSC_COMM_WORLD">PETSC_COMM_WORLD</A>, <font color="#666666">"disc %s size: %d\n"</font>, (*d_iter).c_str(), disc_size);
<a name="line653">653: </a> <font color="#4169E1">for</font> (int i = 0; i < disc_size; i++) {
<a name="line654">654: </a> reorder[disc_indices[i]] = disc_reorder[i] + offset;
<a name="line655">655: </a> //<A href="../../docs/manualpages/Sys/PetscPrintf.html#PetscPrintf">PetscPrintf</A>(<A href="../../docs/manualpages/Sys/PETSC_COMM_WORLD.html#PETSC_COMM_WORLD">PETSC_COMM_WORLD</A>, <font color="#666666">"map closure dof index %d to %d\n"</font>, disc_indices[i], reorder[disc_indices[i]]);
<a name="line656">656: </a> }
<a name="line657">657: </a> offset += disc_size;
<a name="line658">658: </a> //use the discretizations closure indices to reorder the whole-field indices
<a name="line659">659: </a> }
<a name="line660">660: </a> //set the reorder and set all the cell integrals to have this reorder as well. Unfortunately this will take some hacking <font color="#4169E1">for</font> the interior facet integrals.
<a name="line661">661: </a> this->setReorder(reorder);
<a name="line662">662: </a> Obj<names_type> integrals = this->getIntegrals();
<a name="line663">663: </a><strong><font color="#FF0000"> names_type:</font></strong>:iterator i_iter = integrals->begin();
<a name="line664">664: </a><strong><font color="#FF0000"> names_type:</font></strong>:iterator i_iter_end = integrals->end();
<a name="line665">665: </a> <font color="#4169E1">while</font> (i_iter != i_iter_end) {
<a name="line666">666: </a> Obj<GeneralIntegral> integral = this->getIntegral(*i_iter);
<a name="line667">667: </a> integral->setReorder(reorder);
<a name="line668">668: </a> i_iter++;
<a name="line669">669: </a> }
<a name="line670">670: </a> }
<a name="line672">672: </a> virtual void setCell(Obj<PETSC_MESH_TYPE> mesh, PETSC_MESH_TYPE::point_type c) const {
<a name="line673">673: </a> <font color="#4169E1">if</font> (_cell == <A href="../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>) throw Exception(<font color="#666666">"UFCFormSubProblem: Uninitialized cell"</font>);
<a name="line674">674: </a> Obj<PETSC_MESH_TYPE::real_section_type> coords = mesh->getRealSection(<font color="#666666">"coordinates"</font>);
<a name="line675">675: </a> const double * cellcoords = mesh->restrictClosure(coords, c);
<a name="line676">676: </a> int index = 0;
<a name="line677">677: </a> <font color="#4169E1">for</font> (unsigned int i = 0; i < _cell->topological_dimension+1; i++) {
<a name="line678">678: </a> <font color="#4169E1">for</font> (unsigned int j = 0; j < _cell->geometric_dimension; j++) {
<a name="line679">679: </a> _cell->coordinates[i][j] = cellcoords[index];
<a name="line680">680: </a> index++;
<a name="line681">681: </a> }
<a name="line682">682: </a> }
<a name="line683">683: </a> }
<a name="line685">685: </a> ~UFCFormSubProblem(){};
<a name="line686">686: </a>
<a name="line687">687: </a> };
<a name="line688">688: </a> }
<a name="line689">689: </a>}
<a name="line691">691: </a><font color="#A020F0">#endif</font>
</pre>
</body>
</html>
|