Conditions.cpp 30.2 KB
Newer Older
Joe Frazier's avatar
Joe Frazier committed
1
2
////////////////////////////////////////////////////////////////////////////////
//
3
//  File: BoundaryConditions.cpp
Joe Frazier's avatar
Joe Frazier committed
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
//
//  For more information, please see: http://www.nektar.info/
//
//  The MIT License
//
//  Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
//  Department of Aeronautics, Imperial College London (UK), and Scientific
//  Computing and Imaging Institute, University of Utah (USA).
//
//  License for the specific language governing rights and limitations under
//  Permission is hereby granted, free of charge, to any person obtaining a
//  copy of this software and associated documentation files (the "Software"),
//  to deal in the Software without restriction, including without limitation
//  the rights to use, copy, modify, merge, publish, distribute, sublicense,
//  and/or sell copies of the Software, and to permit persons to whom the
//  Software is furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included
//  in all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
//  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
//  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
//  DEALINGS IN THE SOFTWARE.
//
//  Description:
//
//
////////////////////////////////////////////////////////////////////////////////

37
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
38
#include <SpatialDomains/Conditions.h>
39
#include <tinyxml/tinyxml.h>
40

Joe Frazier's avatar
Joe Frazier committed
41
42
43
44
namespace Nektar
{
    namespace SpatialDomains
    {
45
        BoundaryConditions::BoundaryConditions(const LibUtilities::SessionReaderSharedPtr &pSession, const MeshGraphSharedPtr &meshGraph)
46
47
            : m_session(pSession),
              m_meshGraph(meshGraph)
Joe Frazier's avatar
Joe Frazier committed
48
        {
49
            Read(m_session->GetElement("Nektar/Conditions"));
Joe Frazier's avatar
Joe Frazier committed
50
51
52
53
54
55
        }

        BoundaryConditions::~BoundaryConditions()
        {
        }

56

57
58
59
60
        /**
         *
         */
        void BoundaryConditions::Read(TiXmlElement *conditions)
Joe Frazier's avatar
Joe Frazier committed
61
        {
62
            ASSERTL0(conditions, "Unable to find CONDITIONS tag in file.");
63

64
            TiXmlElement *boundaryRegions = conditions->FirstChildElement("BOUNDARYREGIONS");
Joe Frazier's avatar
Joe Frazier committed
65

66
67
68
            if(boundaryRegions)
            {
                ReadBoundaryRegions(conditions);
69

70
71
                ReadBoundaryConditions(conditions);
            }
Joe Frazier's avatar
Joe Frazier committed
72
73
74
        }


75
76
77
        /**
         *
         */
Joe Frazier's avatar
Joe Frazier committed
78
79
        void BoundaryConditions::ReadBoundaryRegions(TiXmlElement *conditions)
        {
80
81
            TiXmlElement *boundaryRegions = conditions->FirstChildElement("BOUNDARYREGIONS");
            ASSERTL0(boundaryRegions, "Unable to find BOUNDARYREGIONS block.");
Joe Frazier's avatar
Joe Frazier committed
82
83
84
85

            int regionIndx = 0;

            // See if we have boundary regions defined.
86
87
88
89
            TiXmlElement *boundaryRegionsElement = boundaryRegions->FirstChildElement("B");

            // Sequential counter for the composite numbers.
            int nextBoundaryRegionNumber = -1;
Joe Frazier's avatar
Joe Frazier committed
90

91
            while (boundaryRegionsElement)
Joe Frazier's avatar
Joe Frazier committed
92
            {
93
94
95
96
97
98
                /// All elements are of the form: "<B ID="#"> ... </B>", with
                /// ? being the element type.

                nextBoundaryRegionNumber++;

                int indx;
Joe Frazier's avatar
Joe Frazier committed
99
                int err = boundaryRegionsElement->QueryIntAttribute("ID", &indx);
100
101
102
103
104
105
106
107
108
                ASSERTL0(err == TIXML_SUCCESS, "Unable to read attribute ID.");
                ASSERTL0(indx == nextBoundaryRegionNumber, "Boundary region IDs must begin with zero and be sequential.");

                TiXmlNode* boundaryRegionChild = boundaryRegionsElement->FirstChild();
                // This is primarily to skip comments that may be present.
                // Comments appear as nodes just like elements.
                // We are specifically looking for text in the body
                // of the definition.
                while(boundaryRegionChild && boundaryRegionChild->Type() != TiXmlNode::TEXT)
Joe Frazier's avatar
Joe Frazier committed
109
                {
110
111
                    boundaryRegionChild = boundaryRegionChild->NextSibling();
                }
Joe Frazier's avatar
Joe Frazier committed
112

113
114
                ASSERTL0(boundaryRegionChild, "Unable to read variable definition body.");
                std::string boundaryRegionStr = boundaryRegionChild->ToText()->ValueStr();
Joe Frazier's avatar
Joe Frazier committed
115

116
117
                std::string::size_type indxBeg = boundaryRegionStr.find_first_of('[') + 1;
                std::string::size_type indxEnd = boundaryRegionStr.find_last_of(']') - 1;
Joe Frazier's avatar
Joe Frazier committed
118

119
                ASSERTL0(indxBeg <= indxEnd, (std::string("Error reading boundary region definition:") + boundaryRegionStr).c_str());
Joe Frazier's avatar
Joe Frazier committed
120

121
                std::string indxStr = boundaryRegionStr.substr(indxBeg, indxEnd - indxBeg + 1);
Joe Frazier's avatar
Joe Frazier committed
122

123
124
                if (!indxStr.empty())
                {
125
                    // Extract the composites from the string and return them in a list.
126
                    BoundaryRegionShPtr boundaryRegion(MemoryManager<BoundaryRegion>::AllocateSharedPtr());
127
                    m_meshGraph->GetCompositeList(indxStr, *boundaryRegion);
Joe Frazier's avatar
Joe Frazier committed
128

129
                    m_boundaryRegions.push_back(boundaryRegion);
Joe Frazier's avatar
Joe Frazier committed
130
131
                }

132
                boundaryRegionsElement = boundaryRegionsElement->NextSiblingElement("B");
Joe Frazier's avatar
Joe Frazier committed
133
134
135
            }
        }

136
137
138
139

        /**
         *
         */
140
        void BoundaryConditions::ReadBoundaryConditions(TiXmlElement *conditions)
Joe Frazier's avatar
Joe Frazier committed
141
        {
142
143
144
145
146
147
            // Read REGION tags
            TiXmlElement *boundaryConditionsElement = conditions->FirstChildElement("BOUNDARYCONDITIONS");
            ASSERTL0(boundaryConditionsElement, "Boundary conditions must be specified.");

            TiXmlElement *regionElement = boundaryConditionsElement->FirstChildElement("REGION");

148
            // Read R (Robin), D (Dirichlet), N (Neumann), P (Periodic) [What about Cauchy?] tags
149
150
            while (regionElement)
            {
151
                BoundaryConditionMapShPtr boundaryConditions = MemoryManager<BoundaryConditionMap>::AllocateSharedPtr();
152

153
                int boundaryRegionID;
Joe Frazier's avatar
Joe Frazier committed
154
                int err = regionElement->QueryIntAttribute("REF", &boundaryRegionID);
155
156
157
158
159
160
                ASSERTL0(err == TIXML_SUCCESS, "Error reading boundary region reference.");

                // Find the boundary region corresponding to this ID.
                std::string boundaryRegionIDStr;
                std::ostringstream boundaryRegionIDStrm(boundaryRegionIDStr);
                boundaryRegionIDStrm << boundaryRegionID;
161
                ASSERTL0(boundaryRegionID < m_boundaryRegions.size(),
162
                (std::string("Boundary region ID not found: ") + boundaryRegionIDStr).c_str());
163
164

                // Here is the boundary region.
165
                // m_boundaryRegions[boundaryRegionID];
166
167

                TiXmlElement *conditionElement = regionElement->FirstChildElement();
168
                std::vector<std::string> vars = m_session->GetVariables();
169
170
171
172
173
174
175
176

                while (conditionElement)
                {
                    // Check type.
                    std::string conditionType = conditionElement->Value();
                    std::string attrData;

                    // All have var specified, or else all variables are zero.
Joe Frazier's avatar
Joe Frazier committed
177
                    TiXmlAttribute *attr = conditionElement->FirstAttribute();
178

179
                    std::vector<std::string>::iterator iter;
Joe Frazier's avatar
Joe Frazier committed
180
                    std::string attrName;
181

182
                    attrData = conditionElement->Attribute("VAR");
183

184
185
                    if (!attrData.empty())
                    {
186
187
                        iter = std::find(vars.begin(), vars.end(), attrData);
                        ASSERTL0(iter != vars.end(), (std::string("Cannot find variable: ") + attrData).c_str());
188
189
190
191
192
193
194
                    }

                    if (conditionType == "N")
                    {
                        if (attrData.empty())
                        {
                            // All variables are Neumann and are set to zero.
195
196
                            for (std::vector<std::string>::iterator varIter = vars.begin();
                                varIter != vars.end(); ++varIter)
197
                            {
198
                                BoundaryConditionShPtr neumannCondition(MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(m_session,"00.0"));
199
                                (*boundaryConditions)[*varIter]  = neumannCondition;
200
                            }
201
                        }                       
202
203
204
205
206
207
208
                        else
                        {
                            // Use the iterator from above, which must point to the variable.
                            attr = attr->Next();

                            if (attr)
                            {
209
                                std::string equation, userDefined, filename;
210

211
212
                                while(attr) 
                                {
213

Sophia Han's avatar
Sophia Han committed
214
                                    attrName = attr->Name();
215

216
217
                                    if (attrName=="USERDEFINEDTYPE") 
                                    {
218

219
220
221
222
223
                                        // Do stuff for the user defined attribute
                                        attrData = attr->Value();
                                        ASSERTL0(!attrData.empty(), "USERDEFINEDTYPE attribute must have associated value.");

                                        // Suppose to go here?
224
                                        m_session->SubstituteExpressions(attrData);
225
226
227
228
229
230

                                        userDefined = attrData;
                                     }
                                     else if(attrName=="VALUE")
                                     {
                                        ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());
231

232
233
234
                                        attrData = attr->Value();
                                        ASSERTL0(!attrData.empty(), "VALUE attribute must be specified.");

235
                                        m_session->SubstituteExpressions(attrData);
236
237

                                        equation = attrData;
238
                                      }
239
240
241
242
243
244
245
246
247
248
249
                                     else if(attrName=="FILE")
                                     {
                                        ASSERTL0(attrName == "FILE", (std::string("Unknown attribute: ") + attrName).c_str());

                                        attrData = attr->Value();
                                        ASSERTL0(!attrData.empty(), "FILE attribute must be specified.");

                                        m_session->SubstituteExpressions(attrData);

                                        filename = attrData;
                                      }
250
                                      attr = attr->Next();
251
                                }
252
                                BoundaryConditionShPtr neumannCondition(MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(m_session, equation, userDefined, filename));
253
                                (*boundaryConditions)[*iter]  = neumannCondition;
254
255
256
257
                            }
                            else
                            {
                                // This variable's condition is zero.
258
                                BoundaryConditionShPtr neumannCondition(MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(m_session, "0"));
259
                                (*boundaryConditions)[*iter]  = neumannCondition;
260
261
262
263
264
265
266
267
                            }
                        }
                    }
                    else if (conditionType == "D")
                    {
                        if (attrData.empty())
                        {
                            // All variables are Dirichlet and are set to zero.
268
269
                            for (std::vector<std::string>::iterator varIter = vars.begin();
                                varIter != vars.end(); ++varIter)
270
                            {
271
                                BoundaryConditionShPtr dirichletCondition(MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(m_session, "0"));
272
                                (*boundaryConditions)[*varIter] = dirichletCondition;
273
274
275
276
277
278
279
280
281
                            }
                        }
                        else
                        {
                            // Use the iterator from above, which must point to the variable.
                            attr = attr->Next();

                            if (attr)
                            {
282
                                std::string equation, userDefined, filename;
283

284
                                while(attr) {
285

286
                                   attrName = attr->Name();
287

288
                                    if (attrName=="USERDEFINEDTYPE") {
289

290
291
292
                                        // Do stuff for the user defined attribute
                                        attrData = attr->Value();
                                        ASSERTL0(!attrData.empty(), "USERDEFINEDTYPE attribute must have associated value.");
293

294
                                        m_session->SubstituteExpressions(attrData);
295

296
297
298
                                        userDefined = attrData;
                                    }
                                    else if(attrName=="VALUE")
299
                                    {
300
                                        ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());
301

302
303
                                        attrData = attr->Value();
                                        ASSERTL0(!attrData.empty(), "VALUE attribute must have associated value.");
304

305
                                        m_session->SubstituteExpressions(attrData);
306
307
308

                                        equation = attrData;
                                    }
309
310
311
312
313
314
315
316
317
318
319
                                    else if(attrName=="FILE")
                                    {
                                       ASSERTL0(attrName == "FILE", (std::string("Unknown attribute: ") + attrName).c_str());

                                       attrData = attr->Value();
                                       ASSERTL0(!attrData.empty(), "FILE attribute must be specified.");

                                       m_session->SubstituteExpressions(attrData);

                                       filename = attrData;
                                     }
320
321
                                   attr = attr->Next();
                                }
322

323
                                BoundaryConditionShPtr dirichletCondition(MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(m_session, equation, userDefined, filename));
324
                                (*boundaryConditions)[*iter]  = dirichletCondition;
325
326
327
328
                            }
                            else
                            {
                                // This variable's condition is zero.
329
                                BoundaryConditionShPtr dirichletCondition(MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(m_session, "0"));
330
                                (*boundaryConditions)[*iter]  = dirichletCondition;
331
332
333
                            }
                        }
                    }
334
                    else if (conditionType == "R") // Read du/dn +  PRIMCOEFF u = VALUE
335
336
337
338
                    {
                        if (attrData.empty())
                        {
                            // All variables are Robin and are set to zero.
339
340
                            for (std::vector<std::string>::iterator varIter = vars.begin();
                                varIter != vars.end(); ++varIter)
341
                            {
342
                                BoundaryConditionShPtr robinCondition(MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(m_session, "0", "0"));
343
                                (*boundaryConditions)[*varIter] = robinCondition;
344
345
346
347
                            }
                        }
                        else
                        {
348
349
350
                            // Use the iterator from above, which must
                            // point to the variable.  Read the A and
                            // B attributes.
351
                            attr = attr->Next();
Spencer Sherwin's avatar
Spencer Sherwin committed
352
                            
353
354
                            if (attr)
                            {
355
356
                                std::string attrName1;
                                std::string attrData1;
357
                                std::string equation1, equation2, userDefined;
358
                                std::string filename;
359

360
                                while(attr){
361

362
                                attrName1 = attr->Name();
363

Sophia Han's avatar
Sophia Han committed
364
                                if (attrName1=="USERDEFINEDTYPE") {
365

366
367
368
                                    // Do stuff for the user defined attribute
                                    attrData1 = attr->Value();
                                    ASSERTL0(!attrData1.empty(), "USERDEFINEDTYPE attribute must have associated value.");
369

370
                                    m_session->SubstituteExpressions(attrData1);
371

372
                                    userDefined = attrData1;
373

374
375
                                 }
                                 else if(attrName1 == "VALUE"){
376

377
                                    ASSERTL0(attrName1 == "VALUE", (std::string("Unknown attribute: ") + attrName1).c_str());
378
379

                                    attrData1 = attr->Value();
380
                                    ASSERTL0(!attrData1.empty(), "VALUE attributes must have associated values.");
381

382
                                    m_session->SubstituteExpressions(attrData1);
383
384

                                    equation1 = attrData1;
385

386
                                    attr = attr->Next();
387
                                    ASSERTL0(attr, "Unable to read PRIMCOEFF attribute.");
388

389
                                    attrName1= attr->Name();
390
                                    ASSERTL0(attrName1 == "PRIMCOEFF", (std::string("Unknown attribute: ") + attrName1).c_str());
391
392

                                    attrData1 = attr->Value();
393
                                    ASSERTL0(!attrData1.empty(), "PRIMCOEFF attributes must have associated values.");
394

395
                                    m_session->SubstituteExpressions(attrData1);
396

397
                                    equation2 = attrData1;
398

399
                                 }
400
401
402
403
404
405
406
407
408
409
410
                                 else if(attrName1=="FILE")
                                 {
                                    ASSERTL0(attrName1 == "FILE", (std::string("Unknown attribute: ") + attrName1).c_str());

                                    attrData1 = attr->Value();
                                    ASSERTL0(!attrData1.empty(), "FILE attribute must be specified.");

                                    m_session->SubstituteExpressions(attrData1);

                                    filename = attrData1;
                                 }
411
                                 attr = attr->Next();
412

413
                                }
414

415
                                BoundaryConditionShPtr robinCondition(MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(m_session, equation1, equation2, userDefined, filename));
416
                                (*boundaryConditions)[*iter]  = robinCondition;
417
418
419
420
                            }
                            else
                            {
                                // This variable's condition is zero.
421
                                BoundaryConditionShPtr robinCondition(MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(m_session, "0", "0"));
422
                                (*boundaryConditions)[*iter]  = robinCondition;
423
424
425
                            }
                        }
                    }
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
                    else if (conditionType == "P")
                    {
                        if (attrData.empty())
                        {
                            attr = attr->Next();

                            if (attr)
                            {
                                attrName = attr->Name();

                                ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());

                                attrData = attr->Value();
                                ASSERTL0(!attrData.empty(), "VALUE attribute must have associated value.");

                                int beg = attrData.find_first_of("[");
                                int end = attrData.find_first_of("]");
                                std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
444
                                ASSERTL0(beg < end, (std::string("Error reading periodic boundary region definition for boundary region: ")
Sophia Han's avatar
Sophia Han committed
445
                                                      + boundaryRegionIDStrm.str()).c_str());
446
447
448
449

                                vector<unsigned int> periodicBndRegionIndex;
                                bool parseGood = ParseUtils::GenerateSeqVector(periodicBndRegionIndexStr.c_str(), periodicBndRegionIndex);

450
                                ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string("Unable to read periodic boundary condition for boundary region: ")
Sophia Han's avatar
Sophia Han committed
451
                                                                              + boundaryRegionIDStrm.str()).c_str());
452
453
454

                                BoundaryConditionShPtr periodicCondition(MemoryManager<PeriodicBoundaryCondition>::AllocateSharedPtr(periodicBndRegionIndex[0]));

455
456
                                for (std::vector<std::string>::iterator varIter = vars.begin();
                                     varIter != vars.end(); ++varIter)
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
                                {
                                    (*boundaryConditions)[*varIter] = periodicCondition;
                                }
                            }
                            else
                            {
                                ASSERTL0(false, "Periodic boundary conditions should be explicitely defined");
                            }
                        }
                        else
                        {
                            // Use the iterator from above, which must point to the variable.
                            // Read the VALUE attribute.  It is the next and only other attribute.
                            attr = attr->Next();

                            if (attr)
                            {
                                attrName = attr->Name();

                                ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());

                                attrData = attr->Value();
                                ASSERTL0(!attrData.empty(), "VALUE attribute must have associated value.");

                                int beg = attrData.find_first_of("[");
                                int end = attrData.find_first_of("]");
                                std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
484
                                ASSERTL0(beg < end, (std::string("Error reading periodic boundary region definition for boundary region: ")
485
486
487
488
489
                                                     + boundaryRegionIDStrm.str()).c_str());

                                vector<unsigned int> periodicBndRegionIndex;
                                bool parseGood = ParseUtils::GenerateSeqVector(periodicBndRegionIndexStr.c_str(), periodicBndRegionIndex);

490
                                ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string("Unable to read periodic boundary condition for boundary region: ") + boundaryRegionIDStrm.str()).c_str());
491
492
493
494
495
496
497
498
499
500

                                BoundaryConditionShPtr periodicCondition(MemoryManager<PeriodicBoundaryCondition>::AllocateSharedPtr(periodicBndRegionIndex[0]));
                                (*boundaryConditions)[*iter]  = periodicCondition;
                            }
                            else
                            {
                                ASSERTL0(false, "Periodic boundary conditions should be explicitely defined");
                            }
                        }
                    }
501
502
503
504
                    else if (conditionType == "C")
                    {
                        NEKERROR(ErrorUtil::ewarning, "Cauchy type boundary conditions not implemented.");
                    }
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
					else if (conditionType == "JUNCTION")
                    {						
                        if (attrData.empty())
                        {
                            ASSERTL0(false, "JUNCTION not set up correctly");
                        }
                        else
                        {
                            // Use the iterator from above, which must point to the variable.
                            attr = attr->Next();
							
                            if (attr)
                            {
                                int P = 0;
								int D1 = 0;
								
                                while(attr) {
									
									attrName = attr->Name();
									
                                    if (attrName=="P") {
										
                                        // Do stuff for the user defined attribute
                                        attrData = attr->Value();	
                                        m_session->SubstituteExpressions(attrData);
                                        P = atoi(attrData.c_str());
                                    }
									else if (attrName=="D1") {
						 
										// Do stuff for the user defined attribute
										attrData = attr->Value();
										m_session->SubstituteExpressions(attrData);
										D1 = atoi(attrData.c_str());

									}
									attr = attr->Next();
                                }
								
                                BoundaryConditionShPtr junctionCondition(MemoryManager<JunctionBoundaryCondition>::AllocateSharedPtr(P, D1));
                                (*boundaryConditions)[*iter]  = junctionCondition;
                            }
                        }
						
                    }
					else if (conditionType == "BIFURCATION")
                    {						
                        if (attrData.empty())
                        {
                            ASSERTL0(false, "BIFURCATION not set up correctly");
                        }
                        else
                        {
                            // Use the iterator from above, which must point to the variable.
                            attr = attr->Next();
							
                            if (attr)
                            {
                                int P = 0;
								int D1 = 0;
								int D2 = 0;
								
								std::string userDefined;
								
                                while(attr) {
									
									attrName = attr->Name();
									
                                    if (attrName=="P") {
										
                                        // Do stuff for the user defined attribute
                                        attrData = attr->Value();	
                                        m_session->SubstituteExpressions(attrData);
                                        P = atoi(attrData.c_str());
                                    }
									else if (attrName=="D1") {
										
										// Do stuff for the user defined attribute
										attrData = attr->Value();
										m_session->SubstituteExpressions(attrData);
										D1 = atoi(attrData.c_str());
										
									}
									else if (attrName=="D2") {
										
										// Do stuff for the user defined attribute
										attrData = attr->Value();
										m_session->SubstituteExpressions(attrData);
										D2 = atoi(attrData.c_str());
										
									}
									attr = attr->Next();
                                }
								
                                BoundaryConditionShPtr bifurcationCondition(MemoryManager<BifurcationBoundaryCondition>::AllocateSharedPtr(P, D1, D2));
                                (*boundaryConditions)[*iter]  = bifurcationCondition;
                            }
                        }
                    }
					else if (conditionType == "MERGING")
                    {						
                        if (attrData.empty())
                        {
                            ASSERTL0(false, "MERGING flow condition not set up correctly");
                        }
                        else
                        {
                            // Use the iterator from above, which must point to the variable.
                            attr = attr->Next();
							
                            if (attr)
                            {
                                int P = 0;
								int D1 = 0;
								int D2 = 0;
								
								std::string userDefined;
								
                                while(attr) {
									
									attrName = attr->Name();
									
                                    if (attrName=="P") {
										
                                        // Do stuff for the user defined attribute
                                        attrData = attr->Value();	
                                        m_session->SubstituteExpressions(attrData);
                                        P = atoi(attrData.c_str());
                                    }
									else if (attrName=="D1") {
										
										// Do stuff for the user defined attribute
										attrData = attr->Value();
										m_session->SubstituteExpressions(attrData);
										D1 = atoi(attrData.c_str());
										
									}
									else if (attrName=="D2") {
										
										// Do stuff for the user defined attribute
										attrData = attr->Value();
										m_session->SubstituteExpressions(attrData);
										D2 = atoi(attrData.c_str());
										
									}
									attr = attr->Next();
                                }
								
                                BoundaryConditionShPtr mergingCondition(MemoryManager<MergingBoundaryCondition>::AllocateSharedPtr(P, D1, D2));
                                (*boundaryConditions)[*iter]  = mergingCondition;
                            }
                        }
                    }
					
					
659
660
661
662

                    conditionElement = conditionElement->NextSiblingElement();
                }

663
                m_boundaryConditions[boundaryRegionID] = boundaryConditions;
664
665
666
                regionElement = regionElement->NextSiblingElement("REGION");
            }
       }
Joe Frazier's avatar
Joe Frazier committed
667
668
    }
}