avtChomboFileFormat.C 94.3 KB
Newer Older
hrchilds's avatar
hrchilds committed
1
2
/*****************************************************************************
*
brugger's avatar
   
brugger committed
3
* Copyright (c) 2000 - 2009, Lawrence Livermore National Security, LLC
hrchilds's avatar
hrchilds committed
4
* Produced at the Lawrence Livermore National Laboratory
brugger's avatar
   
brugger committed
5
* LLNL-CODE-400124
hrchilds's avatar
hrchilds committed
6
7
* All rights reserved.
*
brugger's avatar
   
brugger committed
8
* This file is  part of VisIt. For  details, see https://visit.llnl.gov/.  The
hrchilds's avatar
hrchilds committed
9
10
11
12
13
14
15
16
17
18
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution  and  use  in  source  and  binary  forms,  with  or  without
* modification, are permitted provided that the following conditions are met:
*
*  - Redistributions of  source code must  retain the above  copyright notice,
*    this list of conditions and the disclaimer below.
*  - Redistributions in binary form must reproduce the above copyright notice,
*    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
brugger's avatar
   
brugger committed
19
20
21
*    documentation and/or other materials provided with the distribution.
*  - Neither the name of  the LLNS/LLNL nor the names of  its contributors may
*    be used to endorse or promote products derived from this software without
hrchilds's avatar
hrchilds committed
22
23
24
25
26
*    specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
brugger's avatar
   
brugger committed
27
28
29
* ARE  DISCLAIMED. IN  NO EVENT  SHALL LAWRENCE  LIVERMORE NATIONAL  SECURITY,
* LLC, THE  U.S.  DEPARTMENT OF  ENERGY  OR  CONTRIBUTORS BE  LIABLE  FOR  ANY
* DIRECT,  INDIRECT,   INCIDENTAL,   SPECIAL,   EXEMPLARY,  OR   CONSEQUENTIAL
hrchilds's avatar
hrchilds committed
30
31
32
33
34
35
36
37
38
* DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
* SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
* CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
* LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
* OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/

hrchilds's avatar
hrchilds committed
39
40
41
42
43
44
45
46
// ************************************************************************* //
//                           avtChomboFileFormat.C                           //
// ************************************************************************* //

#include <avtChomboFileFormat.h>

#include <snprintf.h>
#include <string>
ghweber's avatar
ghweber committed
47
#include <cstring>
48
#include <limits>
49
#include <algorithm>
hrchilds's avatar
hrchilds committed
50
51

#include <vtkFieldData.h>
52
#include <vtkCellData.h>
hrchilds's avatar
hrchilds committed
53
#include <vtkFloatArray.h>
54
#include <vtkDoubleArray.h>
hrchilds's avatar
hrchilds committed
55
#include <vtkIntArray.h>
56
#include <vtkUnsignedCharArray.h>
hrchilds's avatar
hrchilds committed
57
58
#include <vtkRectilinearGrid.h>
#include <vtkUnstructuredGrid.h>
59
#include <vtkCellType.h>
hrchilds's avatar
hrchilds committed
60

61
62
#include <DBOptionsAttributes.h>

hrchilds's avatar
hrchilds committed
63
64
65
66
67
68
#include <avtDatabase.h>
#include <avtDatabaseMetaData.h>
#include <avtIntervalTree.h>
#include <avtStructuredDomainBoundaries.h>
#include <avtStructuredDomainNesting.h>
#include <avtVariableCache.h>
69
#include <avtMaterial.h>
hrchilds's avatar
hrchilds committed
70
71
72

#include <Expression.h>

73
#include <FileFunctions.h>
ghweber's avatar
ghweber committed
74

hrchilds's avatar
hrchilds committed
75
76
77
78
79
#include <BadDomainException.h>
#include <DebugStream.h>
#include <InvalidDBTypeException.h>
#include <InvalidFilesException.h>
#include <InvalidVariableException.h>
80
#include <TimingsManager.h>
hrchilds's avatar
hrchilds committed
81

82
83
84
85
86
87
88
// Define this symbol BEFORE including hdf5.h to indicate the HDF5 code
// in this file uses version 1.6 of the HDF5 API. This is harmless for
// versions of HDF5 before 1.8 and ensures correct compilation with
// version 1.8 and thereafter. When, and if, the HDF5 code in this file
// is explicitly upgraded to the 1.8 API, this symbol should be removed.
#define H5_USE_16_API
#include <hdf5.h>
hrchilds's avatar
hrchilds committed
89
#include <visit-hdf5.h>
hrchilds's avatar
hrchilds committed
90
91
92
93
94
95
96
97
98
99

using     std::string;


// ****************************************************************************
//  Method: avtChomboFileFormat constructor
//
//  Programmer: childs -- generated by xml2avt
//  Creation:   Thu Jan 19 11:17:14 PDT 2006
//
hrchilds's avatar
hrchilds committed
100
101
102
103
//  Modifications:
//    Brad Whitlock, Mon Sep 25 13:59:20 PST 2006
//    Initialize the cycle and time.
//
104
105
106
//    Hank Childs, Mon Oct  8 17:17:24 PDT 2007
//    Initialized atts.
//
ghweber's avatar
ghweber committed
107
108
109
//    Gunther H. Weber, Tue Apr 15 17:43:30 PDT 2008
//    Add support to automatically import a coordinate mapping file via conn_cmfe
//
ghweber's avatar
ghweber committed
110
111
112
//    Gunther H. Weber, Thu Apr 17 14:29:25 PDT 2008
//    Check if an option exists before querying its value
//
113
114
115
//    Hank Childs, Sun Jan 25 15:39:08 PST 2009
//    Improve support for ghost data.
//
116
117
118
//    Gunther H. Weber, Tue Sep 15 11:26:12 PDT 2009
//    Added support for 3D mappings for 2D files.
//
119
120
121
//    Hank Childs, Fri Mar  5 13:16:52 PST 2010
//    Initialize hasParticles.
//
hrchilds's avatar
hrchilds committed
122
123
// ****************************************************************************

124
125
avtChomboFileFormat::avtChomboFileFormat(const char *filename, 
                                         DBOptionsAttributes *atts)
hrchilds's avatar
hrchilds committed
126
127
128
    : avtSTMDFileFormat(&filename, 1)
{
    initializedReader = false;
129
130
    allowedToUseGhosts = true;
    fileContainsGhosts = false;
ghweber's avatar
ghweber committed
131
132
133
    enableOnlyRootLevel = false;
    enableOnlyExplicitMaterials = false;
    checkForMappingFile = true;
134
135
    mappingFileExists = false;
    mappingIs3D = false;
136
    hasParticles = false;
137
    if (atts != NULL)
138
    {
ghweber's avatar
ghweber committed
139
140
141
        for (int i = 0; i < atts->GetNumberOfOptions(); ++i)
        {
            if (atts->GetName(i) == "Use ghost data (if present)")
142
                allowedToUseGhosts = atts->GetBool("Use ghost data (if present)");
ghweber's avatar
ghweber committed
143
144
145
146
147
148
149
150
151
            else if (atts->GetName(i) == "Enable only root level by default")
                enableOnlyRootLevel = atts->GetBool("Enable only root level by default");
            else if (atts->GetName(i) == "Enable only explicitly defined materials by default")
                enableOnlyExplicitMaterials = atts->GetBool("Enable only explicitly defined materials by default");
            else if (atts->GetName(i) == "Check for mapping file and import coordinates if available")
                checkForMappingFile = atts->GetBool("Check for mapping file and import coordinates if available");
            else
                debug1 << "Ignoring unknown option " << atts->GetName(i) << endl;
        }
152
153
    }

hrchilds's avatar
hrchilds committed
154
    file_handle = -1;
hrchilds's avatar
hrchilds committed
155
156
    dtime = 0.;
    cycle = 0;
hrchilds's avatar
hrchilds committed
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
}


// ****************************************************************************
//  Method: avtChomboFileFormat destructor
//
//  Programmer: Hank Childs
//  Creation:   January 22, 2006
//
// ****************************************************************************

avtChomboFileFormat::~avtChomboFileFormat()
{
    FreeUpResources();
}


// ****************************************************************************
//  Method: avtChomboFileFormat::FreeUpResources
//
//  Purpose:
//      When VisIt is done focusing on a particular timestep, it asks that
//      timestep to free up any resources (memory, file descriptors) that
//      it has associated with it.  This method is the mechanism for doing
//      that.
//
//  Programmer: childs -- generated by xml2avt
//  Creation:   Thu Jan 19 11:17:14 PDT 2006
//
hrchilds's avatar
hrchilds committed
186
187
188
189
190
//  Modifications:
//
//    Hank Childs, Mon Jun 19 16:56:26 PDT 2006
//    Add support for ghosts.
//
191
192
193
//    Gunther H. Weber, Thu Oct 11 16:00:16 PDT 2007
//    Clean up expressions from file
//
hrchilds's avatar
hrchilds committed
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// ****************************************************************************

void
avtChomboFileFormat::FreeUpResources(void)
{
    initializedReader = false;
    if (file_handle != -1)
    {
        H5Fclose(file_handle);
        file_handle = -1;
    }
    varnames.clear();
    patchesPerLevel.clear();
    refinement_ratio.clear();
    dx.clear();
    lowI.clear();
    hiI.clear();
    lowJ.clear();
    hiJ.clear();
    lowK.clear();
    hiK.clear();
hrchilds's avatar
hrchilds committed
215
    numGhosts.clear();
216
217
218
    for (std::list<Expression*>::iterator it = expressions.begin(); it != expressions.end(); ++it)
        delete *it;
    expressions.clear();
hrchilds's avatar
hrchilds committed
219
220
}

hrchilds's avatar
hrchilds committed
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
// ****************************************************************************
// Method: avtChomboFileFormat::GetCycle
//
// Purpose: 
//   Get the cycle.
//
// Note:       We have to initialize the reader before returning a cycle
//             so we can accurately read the cycle from the file.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 25 13:58:05 PST 2006
//
// Modifications:
//   
// ****************************************************************************

int
avtChomboFileFormat::GetCycle(void)
{
    InitializeReader();
    return cycle; 
}

// ****************************************************************************
// Method: avtChomboFileFormat::GetTime
//
// Purpose: 
//   Get the cycle.
//
// Note:       We have to initialize the reader before returning a time
//             so we can accurately read the time from the file.
//
// Programmer: Brad Whitlock
// Creation:   Mon Sep 25 13:58:05 PST 2006
//
// Modifications:
//   
// ****************************************************************************

double
avtChomboFileFormat::GetTime(void)
{
    InitializeReader();
    return dtime;
}
hrchilds's avatar
hrchilds committed
266
267
268
269
270
271
272
273
274
275
276
277

// ****************************************************************************
//  Method: avtChomboFileFormat::GetCycleFromFilename
//
//  Purpose:
//      Gets the cycle from the file name.  A custom implementation is needed,
//      because they have file names like "...plt0080.2d.hdf5".  We want the
//      "80".
//  
//  Programmer: Hank Childs
//  Creation:   January 22, 2006
//
hrchilds's avatar
hrchilds committed
278
279
280
281
//  Modifications:
//    Brad Whitlock, Mon Sep 25 13:57:02 PST 2006
//    Added code to support names like plot0.0080.2d.hdf5 where we want the 80.
//
282
283
//    Mark C. Miller, Thu Jun 14 10:26:37 PDT 2007
//    Modified to use regular expression based guess 
284
285
286
//
//    Mark C. Miller, Wed Sep 24 11:43:38 PDT 2008
//    Modified regular expression to meet specifications in ticket 8737
287
288
289
290
291
//
//    Gunther H. Weber, Wed Jul 22 11:48:18 PDT 2009
//    Modified regular expression to meet new specifications set by Terry
//    Ligocki (ANAG/APDEC).
//
hrchilds's avatar
hrchilds committed
292
293
294
295
296
// ****************************************************************************

int
avtChomboFileFormat::GetCycleFromFilename(const char *fname) const
{
297
    if (fname == 0 || fname[0] == '\0')
298
299
300
301
        return avtFileFormat::INVALID_CYCLE;
    else 
        return GuessCycle(fname,
                "<^.*[^0-9]([0-9][0-9]*)\\.(2|3)[dD]\\.(hdf5|h5)$> \\1");
hrchilds's avatar
hrchilds committed
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
}


// ****************************************************************************
//  Method: avtChomboFileFormat::ActivateTimestep
//
//  Purpose:
//      Tells the reader it can now do some initialization work.
//  
//  Programmer: Hank Childs
//  Creation:   January 22, 2006
//
// ****************************************************************************

void
avtChomboFileFormat::ActivateTimestep(void)
{
    InitializeReader();
}


// ****************************************************************************
//  Method: avtChomboFileFormat::InitializeReader
//
//  Purpose:
//      Walks through the HDF5 file and reads in some non-problem size data.
//  
//  Programmer: Hank Childs
//  Creation:   January 22, 2006
//
hrchilds's avatar
hrchilds committed
332
333
334
335
336
337
338
339
//  Modifications:
//
//    Hank Childs, Mon Jun 19 14:51:26 PDT 2006
//    Add support for when "time" is placed at "level_0".
//
//    Hank Childs, Mon Jun 19 16:44:06 PDT 2006
//    Added support for ghost zones.
//
hrchilds's avatar
hrchilds committed
340
341
342
343
//    Brad Whitlock, Mon Sep 25 15:22:38 PST 2006
//    I made it revert to cycles from the filename in the event that cycles
//    are not in the file.
//
344
345
346
347
//    Gunther H. Weber, Tue Aug  7 15:58:03 PDT 2007
//    Added check for variables specifying material fractions (variable name
//    fraction-<i>)
//
348
349
350
//    Gunther H. Weber, Thu Oct 11 15:49:41 PDT 2007
//    Read expressions from Chombo files.
//
ghweber's avatar
ghweber committed
351
352
353
354
355
356
357
358
//    Gunther H. Weber, Fri Oct 19 16:47:45 PDT 2007
//    Disable  HDF5 diagnostic output while attempting to read information
//    that may not be contained in the data set. Read problem domain from
//    file (used to figure out, which ghost cells are external to the problem).
//
//    Gunther H. Weber, Mon Oct 22 11:22:35 PDT 2007
//    Read information about problem domain [low|hi]Prob[I|J|K] needed
//    to figure out whether a ghost zone is external to the problem.
359
360
361
362
//
//    Gunther H. Weber, Mon Nov 19 14:02:59 PST 2007
//    Added missing H5Tclose in expression reading code.
//
363
364
365
//    Gunther H. Weber, Mon Mar 24 20:46:04 PDT 2008
//    Added support for node centered Chombo data.
//
pugmire's avatar
pugmire committed
366
367
368
//    Dave Pugmire, Fri Aug 22 10:27:39 EDT 2008
//    boxes_buff was leaking.
//
369
370
371
//    Hank Childs, Sun Jan 25 15:43:03 PST 2009
//    Set proper Boolean if we find evidence of ghost data.
//
ghweber's avatar
ghweber committed
372
373
374
//    Gunther H. Weber, Wed Mar 25 13:31:56 PDT 2009
//    Close file to prevent file handle depletion
//
375
376
377
//    Gunther H. Weber, Wed Jun 10 18:28:24 PDT 2009
//    Added ability to handle particle data in Chombo files.
//
378
379
380
//    Gunther H. Weber, Tue Sep 15 11:26:12 PDT 2009
//    Added support for 3D mappings for 2D files.
//
381
382
383
//    Jeremy Meredith, Thu Jan  7 15:36:19 EST 2010
//    Close all open ids when returning an exception.
//
hrchilds's avatar
hrchilds committed
384
385
// ****************************************************************************

386
387
388
389
390
391
392
393
extern "C"  herr_t
add_var(hid_t loc_id, const char *varname, void *opData)
{
  std::list<std::string> *l = (std::list<std::string>*)opData;
  l->push_back(varname);
  return 0;
}

hrchilds's avatar
hrchilds committed
394
395
396
397
398
399
400
401
void
avtChomboFileFormat::InitializeReader(void)
{
    int   i, j;

    if (initializedReader)
        return;

402
403
    debug5 << "avtChomboFileFormat: Initializing reader." << std::endl;

ghweber's avatar
ghweber committed
404
405
406
407
408
409
410
411
412
413
414
415
    //
    // Get current automatic stack traversal function to re-enable it later and
    // disable HDF5's automatic error printing
    //
    H5E_auto_t h5e_autofunc;
    void* h5e_clientdata;
    H5Eget_auto(&h5e_autofunc, &h5e_clientdata);
    H5Eset_auto(0, 0);

    //
    // Open file
    //
hrchilds's avatar
hrchilds committed
416
417
418
419
420
421
422
423
424
425
426
427
428
    file_handle = H5Fopen(filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT);
    if (file_handle < 0)
    {
        EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, since "
                                           "it is not even an HDF5 file.");
    }

    //
    // Most of the global info is stored in the "/" group.
    //
    hid_t slash = H5Gopen(file_handle, "/");
    if (slash < 0)
    {
429
        H5Fclose(file_handle);
hrchilds's avatar
hrchilds committed
430
431
432
433
        EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, must "
                                           "have the \"/\" group.");
    }

hrchilds's avatar
hrchilds committed
434
435
    bool hasTime = false;
    bool hasIterations = false;
436
    bool hasCentering = false;
hrchilds's avatar
hrchilds committed
437
438
439
440
441
442
443
444
445
446
447

    int numAttrs = H5Aget_num_attrs(slash);
    char buf[1024];
    for (i = 0 ; i < numAttrs ; i++)
    {
        hid_t idx = H5Aopen_idx(slash, i);
        H5Aget_name(idx, 1024, buf);
        if (strcmp(buf, "time") == 0)
            hasTime = true;
        if (strcmp(buf, "iteration") == 0)
            hasIterations = true;
448
449
        if (strcmp(buf,"data_centering") == 0)
            hasCentering = true;
hrchilds's avatar
hrchilds committed
450
451
452
        H5Aclose(idx);
    }

hrchilds's avatar
hrchilds committed
453
454
455
    //
    // Get the time.
    //
hrchilds's avatar
hrchilds committed
456
    if (hasTime)
hrchilds's avatar
hrchilds committed
457
    {
hrchilds's avatar
hrchilds committed
458
459
460
        hid_t time_id = H5Aopen_name(slash, "time");
        if (time_id < 0)
        {
461
462
            H5Gclose(slash);
            H5Fclose(file_handle);
hrchilds's avatar
hrchilds committed
463
464
465
466
467
            EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, must "
                                               "have time in \"/\" group.");
        }
        H5Aread(time_id, H5T_NATIVE_DOUBLE, &dtime);
        H5Aclose(time_id);
hrchilds's avatar
hrchilds committed
468
    }
hrchilds's avatar
hrchilds committed
469
470
    else
        dtime = 0.;
hrchilds's avatar
hrchilds committed
471
472
473
474

    //
    // Get the cycle.
    //
hrchilds's avatar
hrchilds committed
475
    if (hasIterations)
hrchilds's avatar
hrchilds committed
476
    {
hrchilds's avatar
hrchilds committed
477
478
479
        hid_t cycle_id = H5Aopen_name(slash, "iteration");
        if (cycle_id < 0)
        {
480
481
            H5Gclose(slash);
            H5Fclose(file_handle);
hrchilds's avatar
hrchilds committed
482
483
484
485
486
            EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, must "
                                             "have iteration in \"/\" group.");
        }
        H5Aread(cycle_id, H5T_NATIVE_INT, &cycle);
        H5Aclose(cycle_id);
hrchilds's avatar
hrchilds committed
487
    }
hrchilds's avatar
hrchilds committed
488
    else
hrchilds's avatar
hrchilds committed
489
        cycle = GetCycleFromFilename(filenames[0]);
hrchilds's avatar
hrchilds committed
490

491
492
493
494
495
496
497
498
499
500
    //
    // Get the centering.
    //
    nodeCentered = false;
    if (hasCentering)
    {
        debug1 << "Chombo file has centering information." << std::endl;
        hid_t time_id = H5Aopen_name(slash, "data_centering");
        if (time_id < 0)
        {
501
502
            H5Gclose(slash);
            H5Fclose(file_handle);
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
            EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, must "
                                               "have data_centering in \"/\" group.");
        }
        int centeringVal;
        H5Aread(time_id, H5T_NATIVE_INT, &centeringVal);
        H5Aclose(time_id);
        if (centeringVal == 7)
        {
            debug1 << "Node centered data." << std::endl;
            nodeCentered = true;
        }
        else
        {
            debug1 << "Cell centered data." << std::endl;
        }
    }

hrchilds's avatar
hrchilds committed
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
    //
    // Note: max_level, per conversation with John Shalf, is for the code
    // to say what the maximum level could be.  We don't need this...
    //
    /*
    int max_level;
    hid_t ml_id = H5Aopen_name(slash, "max_level");
    H5Aread(ml_id, H5T_NATIVE_INT, &max_level);
    H5Aclose(ml_id);
    */

    //
    // Determine how many refinement levels there are.
    //
    hid_t nl_id = H5Aopen_name(slash, "num_levels");
    if (nl_id < 0)
    {
537
538
        H5Gclose(slash);
        H5Fclose(file_handle);
hrchilds's avatar
hrchilds committed
539
540
541
542
        EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, must "
                                           "have num_levels in \"/\" group.");
    }
    H5Aread(nl_id, H5T_NATIVE_INT, &num_levels);
543
    H5Aclose(nl_id);
hrchilds's avatar
hrchilds committed
544
545
546
547
    if (num_levels <= 0)
    {
        debug1 << "ERROR: Number of levels (" << num_levels 
               << ") must be at least 1" << endl;
548
549
        H5Gclose(slash);
        H5Fclose(file_handle);
hrchilds's avatar
hrchilds committed
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
        EXCEPTION1(InvalidFilesException, filenames[0]);
    }

    //
    // Determine how many variables there are.
    //
    int num_vars;
    hid_t nv_id = H5Aopen_name(slash, "num_components");
    if (nv_id < 0)
    {
        EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, must "
                                        "have num_components in \"/\" group.");
    }
    H5Aread(nv_id, H5T_NATIVE_INT, &num_vars);
    if (num_vars < 0)
    {
        debug1 << "ERROR: Number of variables less than 0" << endl;
        EXCEPTION1(InvalidFilesException, filenames[0]);
    }
    H5Aclose(nv_id);

    //
    // Read out each variable name and store it in vector "varnames".
    //
    for (i = 0 ; i < num_vars ; i++)
    {
        char name[1024];
        SNPRINTF(name, 1024, "component_%d", i);
        hid_t vname = H5Aopen_name(slash, name);
        if (vname < 0)
        {
            EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, does "
                                               "not have all component names");
        }
        char name2[1024] = { '\0' };
        hid_t atype = H5Aget_type(vname);
        H5Aread(vname, atype, name2);
        varnames.push_back(name2);
        H5Aclose(vname);
    }

    //
    // We're done reading everything from "slash".
    //
    H5Gclose(slash);

    //
    // Now open up "Chombo_global".
    //
    hid_t global = H5Gopen(file_handle, "Chombo_global");
    if (global < 0)
    {
        EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, does "
                                           "not have Chombo_global");
    }
    hid_t dim_id = H5Aopen_name(global, "SpaceDim");
    if (dim_id < 0)
    {
        EXCEPTION1(InvalidDBTypeException, "Cannot be a Chombo file, does "
                                         "not have SpaceDim in Chombo_global");
    }
    H5Aread(dim_id, H5T_NATIVE_INT, &dimension);
    if (dimension != 2 && dimension != 3)
    {
        debug1 << "ERROR: Reader only supports 2D and 3D data sets." << endl;
        EXCEPTION1(InvalidFilesException, filenames[0]);
    }
    H5Aclose(dim_id);
    H5Gclose(global);

620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
    //
    // Look for epxressions
    //
    hid_t expressionsGroup = H5Gopen(file_handle, "/Expressions");
    if (expressionsGroup > 0)
    {
        for (unsigned int i=0; i<H5Aget_num_attrs(expressionsGroup); ++i)
        {
            // Open expression
            hid_t currExpression = H5Aopen_idx(expressionsGroup, i);

            // Get name, which has form <return type> <name>
            const size_t buffSize = 1024;
            char buffer[buffSize];
            H5Aget_name(currExpression, buffSize, buffer);

            // Split into type and name
ghweber's avatar
ghweber committed
637
            char *separatorPos = std::strchr(buffer, ' ');
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
            *separatorPos = '\0';
            char *exprTypeStr = buffer;
            char *exprName = separatorPos + 1;

            // Parse type
            Expression::ExprType exprType = Expression::Unknown;
            if (strcmp("vector", exprTypeStr) == 0)
                exprType = Expression::VectorMeshVar;
            else if (strcmp("scalar", exprTypeStr) == 0)
                exprType = Expression::ScalarMeshVar;
            else 
                debug1 << "Unknown expression type " << exprType << " in file." << std::endl;

            if (exprType != Expression::Unknown) 
            {
                hid_t strType = H5Aget_type(currExpression);
                hsize_t strLen;
                if (strType >= 0 && H5Tget_class(strType) == H5T_STRING &&
                    (strLen = H5Tget_size(strType)) < buffSize - 1)
                {
                    Expression *newExpression = new Expression;
                    newExpression->SetName(exprName);
                    newExpression->SetType(exprType);
                    newExpression->SetHidden(false);

                    // Read definition
                    H5Aread(currExpression, strType, buffer);
                    buffer[strLen]  = '\0';
                    newExpression->SetDefinition(buffer);
                    expressions.push_back(newExpression);
                }
669
                H5Tclose(strType);
670
671
672
673
674
675
            }
            H5Aclose(currExpression);
        }
        H5Gclose(expressionsGroup);
    }

hrchilds's avatar
hrchilds committed
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
    //
    // Now iterate over each refinement level and determine how many patches
    // there are at that refinement level, what the refinement ratio is, and
    // what "dx" is ... "dx" is the distance between consecutive points.
    //
    int totalPatches = 0;
    patchesPerLevel.resize(num_levels);
    refinement_ratio.resize(num_levels);
    dx.resize(num_levels);
    for (i = 0 ; i < num_levels ; i++)
    {
        char name[1024];
        SNPRINTF(name, 1024, "level_%d", i);
        hid_t level = H5Gopen(file_handle, name);
        if (level < 0)
        {
            EXCEPTION1(InvalidDBTypeException, "Does not contain all "
                                               "refinement levels.");
        }
ghweber's avatar
ghweber committed
695

hrchilds's avatar
hrchilds committed
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
        hid_t boxes = H5Dopen(level, "boxes");
        if (boxes < 0)
        {
            EXCEPTION1(InvalidDBTypeException, "Does not contain \"boxes\".");
        }
        hid_t boxspace = H5Dget_space(boxes);
        hsize_t dims[1], maxdims[1];
        H5Sget_simple_extent_dims(boxspace, dims, maxdims);
        hid_t memdataspace = H5Screate_simple(1, dims, NULL);
        patchesPerLevel[i] = dims[0];
        totalPatches += patchesPerLevel[i];

        hid_t dx_id = H5Aopen_name(level, "dx");
        if (dx_id < 0)
        {
            EXCEPTION1(InvalidDBTypeException, "Does not contain \"dx\".");
        }
        double dx_tmp;
        H5Aread(dx_id, H5T_NATIVE_DOUBLE, &dx_tmp);
        H5Aclose(dx_id);
        dx[i] = dx_tmp;

        hid_t rr_id = H5Aopen_name(level, "ref_ratio");
        if (rr_id < 0)
        {
            EXCEPTION1(InvalidDBTypeException,
                                            "Does not contain \"ref_ratio\".");
        }
        int rr;
        H5Aread(rr_id, H5T_NATIVE_INT, &rr);
        H5Aclose(rr_id);
        refinement_ratio[i] = rr;

hrchilds's avatar
hrchilds committed
729
730
731
732
733
734
735
736
737
738
739
740
        if (!hasTime && i == 0)
        {
            // Some Chombo files put time at level_0 instead of in the "/"
            // directory.  Look for it here.
            hid_t time_id = H5Aopen_name(level, "time");
            if (time_id >= 0)
            {
                H5Aread(time_id, H5T_NATIVE_DOUBLE, &dtime);
                H5Aclose(time_id);
            }
        }

hrchilds's avatar
hrchilds committed
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
        H5Sclose(memdataspace);
        H5Sclose(boxspace);
        H5Dclose(boxes);
        H5Gclose(level);
    }

    // 
    // Now that we know how many total patches there are, create our data
    // structures to hold the extents of each patch.
    //
    lowI.resize(totalPatches);
    hiI.resize(totalPatches);
    lowJ.resize(totalPatches);
    hiJ.resize(totalPatches);
    if (dimension == 3)
    {
        lowK.resize(totalPatches);
        hiK.resize(totalPatches);
    }
ghweber's avatar
ghweber committed
760
761
762
763
764
765
766
767
768
769
770
771
772

    //
    // Also, create space for the problem domain extent for each level
    //
    lowProbI.resize(num_levels);
    hiProbI.resize(num_levels);
    lowProbJ.resize(num_levels);
    hiProbJ.resize(num_levels);
    if (dimension == 3)
    {
        lowProbK.resize(num_levels);
        hiProbK.resize(num_levels);
    }
hrchilds's avatar
hrchilds committed
773
774
775
776
777
    
    //
    // Now iterate over the patches again, storing their extents in our
    // internal data structure.
    //
hrchilds's avatar
hrchilds committed
778
779
780
781
782
783
784
785
786
787
788
789
790
791
    hid_t box2d_id = H5Tcreate (H5T_COMPOUND, sizeof(box));
    H5Tinsert (box2d_id, "lo_i", HOFFSET(box2d, lo.i), H5T_NATIVE_INT);
    H5Tinsert (box2d_id, "lo_j", HOFFSET(box2d, lo.j), H5T_NATIVE_INT);
    H5Tinsert (box2d_id, "hi_i", HOFFSET(box2d, hi.i), H5T_NATIVE_INT);
    H5Tinsert (box2d_id, "hi_j", HOFFSET(box2d, hi.j), H5T_NATIVE_INT);

    hid_t box3d_id = H5Tcreate (H5T_COMPOUND, sizeof(box));
    H5Tinsert (box3d_id, "lo_i", HOFFSET(box3d, lo.i), H5T_NATIVE_INT);
    H5Tinsert (box3d_id, "lo_j", HOFFSET(box3d, lo.j), H5T_NATIVE_INT);
    H5Tinsert (box3d_id, "lo_k", HOFFSET(box3d, lo.k), H5T_NATIVE_INT);
    H5Tinsert (box3d_id, "hi_i", HOFFSET(box3d, hi.i), H5T_NATIVE_INT);
    H5Tinsert (box3d_id, "hi_j", HOFFSET(box3d, hi.j), H5T_NATIVE_INT);
    H5Tinsert (box3d_id, "hi_k", HOFFSET(box3d, hi.k), H5T_NATIVE_INT);

hrchilds's avatar
hrchilds committed
792
793
794
795
796
797
798
799
800
    hid_t intvect2d_id = H5Tcreate (H5T_COMPOUND, sizeof(intvect2d));
    H5Tinsert (intvect2d_id, "intvecti", HOFFSET(intvect2d, i), H5T_NATIVE_INT);
    H5Tinsert (intvect2d_id, "intvectj", HOFFSET(intvect2d, j), H5T_NATIVE_INT);

    hid_t intvect3d_id = H5Tcreate (H5T_COMPOUND, sizeof(intvect3d));
    H5Tinsert (intvect3d_id, "intvecti", HOFFSET(intvect3d, i), H5T_NATIVE_INT);
    H5Tinsert (intvect3d_id, "intvectj", HOFFSET(intvect3d, j), H5T_NATIVE_INT);
    H5Tinsert (intvect3d_id, "intvectk", HOFFSET(intvect3d, k), H5T_NATIVE_INT);

hrchilds's avatar
hrchilds committed
801
802
803
804
805
806
807
808
809
810
811
812
813
    int patchId = 0;
    for (i = 0 ; i < num_levels ; i++)
    {
        char name[1024];
        SNPRINTF(name, 1024, "level_%d", i);

        hid_t level = H5Gopen(file_handle, name);
        hid_t boxes = H5Dopen(level, "boxes");
        hid_t boxspace = H5Dget_space(boxes);
        hsize_t dims[1], maxdims[1];
        H5Sget_simple_extent_dims(boxspace, dims, maxdims);
        hid_t memdataspace = H5Screate_simple(1, dims, NULL);

ghweber's avatar
ghweber committed
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
        //
        // Level 0 contains information about the problem domain
        // 
        if (i == 0)
        {
            hid_t probDomain = H5Aopen_name(level, "prob_domain");
            if (probDomain < 0)
            {
                EXCEPTION1(InvalidDBTypeException, "Does not contain \"prob_domain\".");
            }
            box *probDomain_buff = new box;
            if (H5Aread(probDomain, (dimension == 2 ? box2d_id : box3d_id), probDomain_buff) < 0)
            {
                EXCEPTION1(InvalidDBTypeException, "Cannot read \"prob_domain\".");
            }
            if (dimension == 2)
            {
                lowProbI[0] = probDomain_buff->b2.lo.i;
                hiProbI[0] = probDomain_buff->b2.hi.i;
833
                lowProbJ[0] = probDomain_buff->b2.lo.j;
ghweber's avatar
ghweber committed
834
835
836
837
838
                hiProbJ[0] = probDomain_buff->b2.hi.j;
            }
            else
            {
                lowProbI[0] = probDomain_buff->b3.lo.i;
839
                hiProbI[0] = probDomain_buff->b3.hi.i;
ghweber's avatar
ghweber committed
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
                lowProbJ[0] = probDomain_buff->b3.lo.j;
                hiProbJ[0] = probDomain_buff->b3.hi.j;
                lowProbK[0] = probDomain_buff->b3.lo.k;
                hiProbK[0] = probDomain_buff->b3.hi.k;
            }
            delete probDomain_buff;
            H5Aclose(probDomain);
        }
        else
        {
            // In higher levels, calculate the information using
            // the previous level and refinement ratio
            lowProbI[i] = refinement_ratio[i-1] * lowProbI[i-1];
            hiProbI[i] = refinement_ratio[i-1] * hiProbI[i-1];
            lowProbJ[i] = refinement_ratio[i-1] * lowProbJ[i-1];
            hiProbJ[i] = refinement_ratio[i-1] * hiProbJ[i-1];
            if (dimension == 3)
            {
                lowProbK[i] = refinement_ratio[i-1] * lowProbK[i-1];
                hiProbK[i] = refinement_ratio[i-1] * hiProbK[i-1];
            }
        }

        //
        // Read box information
        //
hrchilds's avatar
hrchilds committed
866
867
868
        box *boxes_buff = new box[dims[0]];
        H5Dread(boxes, (dimension == 2 ? box2d_id : box3d_id), memdataspace, 
                boxspace, H5P_DEFAULT, boxes_buff);
hrchilds's avatar
hrchilds committed
869
870
871

        for (j = 0 ; j < patchesPerLevel[i] ; j++)
        {
hrchilds's avatar
hrchilds committed
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
            if (dimension == 2)
            {
                lowI[patchId] = boxes_buff[j].b2.lo.i;
                lowJ[patchId] = boxes_buff[j].b2.lo.j;
                hiI[patchId] = boxes_buff[j].b2.hi.i+1;
                hiJ[patchId] = boxes_buff[j].b2.hi.j+1;
            }
            else
            {
                lowI[patchId] = boxes_buff[j].b3.lo.i;
                lowJ[patchId] = boxes_buff[j].b3.lo.j;
                lowK[patchId] = boxes_buff[j].b3.lo.k;
                hiI[patchId] = boxes_buff[j].b3.hi.i+1;
                hiJ[patchId] = boxes_buff[j].b3.hi.j+1;
                hiK[patchId] = boxes_buff[j].b3.hi.k+1;
            }
hrchilds's avatar
hrchilds committed
888
889
890
            patchId++;
        }

pugmire's avatar
pugmire committed
891
892
        delete [] boxes_buff;

hrchilds's avatar
hrchilds committed
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
        hid_t data_atts = H5Gopen(level, "data_attributes");
        if (data_atts >= 0)
        {
            hid_t ghost_id = H5Aopen_name(data_atts, "outputGhost");
            if (ghost_id < 0)
            {
                numGhosts.push_back(0);
                numGhosts.push_back(0);
                numGhosts.push_back(0);
            }
            else
            {
                int g[3] = { 0, 0, 0 };
                if (dimension == 2)
                {
                    intvect2d g;
                    H5Aread(ghost_id, intvect2d_id, &g);
                    numGhosts.push_back(g.i);
                    numGhosts.push_back(g.j);
912
913
                    if (g.i > 0 || g.j > 0)
                        fileContainsGhosts = true;
hrchilds's avatar
hrchilds committed
914
915
916
917
918
919
                    numGhosts.push_back(0);
                }
                else
                {
                    intvect3d g;
                    H5Aread(ghost_id, intvect3d_id, &g);
920
921
                    if (g.i > 0 || g.j > 0 || g.k)
                        fileContainsGhosts = true;
hrchilds's avatar
hrchilds committed
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
                    numGhosts.push_back(g.i);
                    numGhosts.push_back(g.j);
                    numGhosts.push_back(g.k);
                }
                H5Aclose(ghost_id);
            }
            H5Gclose(data_atts);
        }
        else
        {
            numGhosts.push_back(0);
            numGhosts.push_back(0);
            numGhosts.push_back(0);
        }
           
hrchilds's avatar
hrchilds committed
937
938
939
940
941
942
        H5Sclose(memdataspace);
        H5Sclose(boxspace);
        H5Dclose(boxes);
        H5Gclose(level);
    }

hrchilds's avatar
hrchilds committed
943
944
945
    H5Tclose(box2d_id);
    H5Tclose(box3d_id);

946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
    //
    // Look for particles
    //
    std::list<std::string> varList;
    if (H5Giterate(file_handle, "/particles", 0, add_var, &varList) == 0)
    {
        bool hasXPos = false;
        bool hasYPos = false;
        bool hasZPos = false;
        for (std::list<std::string>::iterator it = varList.begin(); it != varList.end(); ++it)
        {
            if (*it == "position_x") hasXPos = true;
            else if (*it == "position_y") hasYPos = true;
            else if (*it == "position_z") hasZPos = true;
            else
            {
                particleVarnames.push_back(*it);
            }
        }

        if (hasXPos && hasYPos && (dimension == 2 || hasZPos))
        {
            hasParticles = true;
        }
        else
        {
            debug1 << "Ignoring particles since position information is missing." << std::endl;
        }
    }
 
hrchilds's avatar
hrchilds committed
976
977
978
979
980
981
982
    //
    // The domain nesting takes a while to calculate.  We don't need the
    // data structure if we are on the mdserver.  But we do if we're on the
    // engine.  So only calculate it conditionally.
    //
    if (!avtDatabase::OnlyServeUpMetaData())
    {
983
        int t0 = visitTimer->StartTimer();
hrchilds's avatar
hrchilds committed
984
        CalculateDomainNesting();
985
        visitTimer->StopTimer(t0, "Chombo calculating domain nesting");
hrchilds's avatar
hrchilds committed
986
987
    }

ghweber's avatar
ghweber committed
988
989
    H5Fclose(file_handle);
    file_handle = -1;
hrchilds's avatar
hrchilds committed
990
    initializedReader = true;
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009

    //
    // Find any materials
    //
    nMaterials = 0;
    for (i = 0; i < varnames.size(); ++i)
    {
        int val = 0;
        if (varnames[i].find("fraction-") == 0)
        {
            int val = atoi(varnames[i].c_str()+9) + 1;

            if (val > nMaterials)
                nMaterials = val;
        }
    }

    if (nMaterials != 0)
    {
ahern's avatar
ahern committed
1010
        ++nMaterials; // There is always one extra material
1011
    }
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086

    //
    // Check for mapping file and whether mapping is 3D
    //
    if (checkForMappingFile)
    {
        std::string mappingFilename(filenames[0]);
        size_t extPos = mappingFilename.find(".hdf5");
        if  (extPos == std::string::npos)
        {
            extPos = mappingFilename.find(".h5");
        }

        if (extPos != std::string::npos)
        {
            mappingFilename.insert(extPos, ".map");

            VisItStat_t fs;
            if (VisItStat(mappingFilename.c_str(), &fs) == 0)
            {
                hid_t mapping_file_handle = H5Fopen(mappingFilename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
                if (mapping_file_handle > 0)
                {
                    hid_t slash = H5Gopen(mapping_file_handle, "/");
                    if (slash > 0)
                    {
                        hid_t ncomponents_id = H5Aopen_name(slash, "num_components");
                        if (ncomponents_id > 0)
                        {
                            int mapping_ncomponents;
                            H5Aread(ncomponents_id, H5T_NATIVE_INT, &mapping_ncomponents);
                            if (mapping_ncomponents == 2)
                            {
                                mappingFileExists = true;
                            }
                            else if (mapping_ncomponents == 3)
                            {
                                mappingFileExists = true;
                                mappingIs3D = true;
                            }
                            else
                            {
                                debug1 << "Ignoring mapping file since it has ";
                                debug1 << mapping_ncomponents << " instead of expected ";
                                debug1 << "two or three components." << std::endl;
                            }
                            H5Aclose(ncomponents_id);
                        }
                        else
                        {
                            debug1 << "Ignoring mapping file since it has no ";
                            debug1 << "\"num_components\" attribute" << std::endl;
                        }
                        H5Gclose(slash);
                    }
                    else
                    {
                        debug1 << "Ignoring mapping file since I cannot open its ";
                        debug1 << "root group." << std::endl;
                    }
                    H5Fclose(mapping_file_handle);
                }
                else
                {
                    debug1 << "Igonoring mapping file since it is not an HDF5 file.";
                    debug1 << std::endl;
                }
            }
        }
    }

    //
    // Re-enable HDF5's automatic diagnostic output
    //
    H5Eset_auto(h5e_autofunc, h5e_clientdata);
hrchilds's avatar
hrchilds committed
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
}


// ****************************************************************************
//  Method: avtChomboFileFormat::CalculateDomainNesting
//
//  Purpose:
//      Calculates two important data structures.  One is the structure domain
//      nesting, which tells VisIt how the AMR patches are nested, which allows
//      VisIt to ghost out coarse zones that are refined by smaller zones.
//      The other structure is the rectilinear domain boundaries, which tells
//      VisIt which patches are next to each other, allowing VisIt to create
//      a layer of ghost zones around each patch.  Note that this only works
//      within a refinement level, not across refinement levels.
//  
//  Programmer: Hank Childs
//  Creation:   January 22, 2006
//
1105
1106
1107
1108
1109
//  Modifications:
//
//    Hank Childs, Fri Nov 14 09:11:33 PST 2008
//    Only create the domain boundaries object if we are not using ghost data.
//
1110
1111
1112
1113
//    Hank Childs, Sun Jan 25 15:54:52 PST 2009
//    Improve the test for whether or not to create the domain boundaries
//    object.
//
hrchilds's avatar
hrchilds committed
1114
1115
1116
1117
1118
// ****************************************************************************

void
avtChomboFileFormat::CalculateDomainNesting(void)
{
hrchilds's avatar
hrchilds committed
1119
    int j;
hrchilds's avatar
hrchilds committed
1120
1121
1122
1123
1124
    int level;

    //
    // Calculate some info we will need in the rest of the routine.
    //
1125
    int t0 = visitTimer->StartTimer();
hrchilds's avatar
hrchilds committed
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
    int totalPatches = 0;
    vector<int> levelStart;
    vector<int> levelEnd;
    for (level = 0 ; level < num_levels ; level++)
    {

        levelStart.push_back(totalPatches);
        totalPatches += patchesPerLevel[level];
        levelEnd.push_back(totalPatches);
    }
1136
    visitTimer->StopTimer(t0, "Pre-work for domain nesting");
hrchilds's avatar
hrchilds committed
1137
1138
1139
1140
1141

    //
    // Now that we know the total number of patches, we can allocate the
    // data structure for the patch nesting.
    //
1142
    int t1 = visitTimer->StartTimer();
hrchilds's avatar
hrchilds committed
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
    avtStructuredDomainNesting *dn = new avtStructuredDomainNesting(
                                          totalPatches, num_levels);

    //
    // Calculate what the refinement ratio is from one level to the next.
    //
    vector<int> rr(dimension);
    for (level = 0 ; level < num_levels ; level++)
    {
        if (level == 0)
        {
            for (j = 0 ; j < dimension ; j++)
                rr[j] = 1;
        }
        else
        {
            for (j = 0 ; j < dimension ; j++)
                rr[j] = refinement_ratio[level-1];
        }
        dn->SetLevelRefinementRatios(level, rr);
    }

    //
    // This multiplier will be needed to find out if patches are nested.
    //
    vector<int> multiplier(num_levels);
    multiplier[num_levels-1] = 1;
    for (level = num_levels-2 ; level >= 0 ; level--)
    {
        multiplier[level] = multiplier[level+1]*refinement_ratio[level];
    }
1174
    visitTimer->StopTimer(t1, "Setting up domain nesting: part 1");
hrchilds's avatar
hrchilds committed
1175
1176
1177
1178
1179

    //
    // Now set up the data structure for patch boundaries.  The data 
    // does all the work ... it just needs to know the extents of each patch.
    //
1180
    if (!allowedToUseGhosts || !fileContainsGhosts)
hrchilds's avatar
hrchilds committed
1181
    {
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
        int t2 = visitTimer->StartTimer();
        avtRectilinearDomainBoundaries *rdb 
                                    = new avtRectilinearDomainBoundaries(true);
        rdb->SetNumDomains(totalPatches);
        for (int patch = 0 ; patch < totalPatches ; patch++)
        {
            int my_level, local_patch;
            GetLevelAndLocalPatchNumber(patch, my_level, local_patch);
    
            int e[6];
            e[0] = lowI[patch];
            e[1] = hiI[patch];
            e[2] = lowJ[patch];
            e[3] = hiJ[patch];
            e[4] = (dimension == 2 ? 0 : lowK[patch]);
            e[5] = (dimension == 2 ? 0 : hiK[patch]);
    
            rdb->SetIndicesForAMRPatch(patch, my_level, e);
        }
        rdb->CalculateBoundaries();
        void_ref_ptr vrdb = void_ref_ptr(rdb,
                                       avtStructuredDomainBoundaries::Destruct);
        cache->CacheVoidRef("any_mesh", AUXILIARY_DATA_DOMAIN_BOUNDARY_INFORMATION,
                            timestep, -1, vrdb);
        visitTimer->StopTimer(t2, "Chombo reader doing rect domain boundaries");
hrchilds's avatar
hrchilds committed
1207
1208
1209
    }

    //
1210
    // Calculate the child patches.
hrchilds's avatar
hrchilds committed
1211
    //
1212
    int t3 = visitTimer->StartTimer();
hrchilds's avatar
hrchilds committed
1213
1214
1215
1216
    vector< vector<int> > childPatches(totalPatches);
    for (level = num_levels-1 ; level > 0 ; level--)
    {
        int prev_level = level-1;
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
        int coarse_start  = levelStart[prev_level];
        int coarse_end    = levelEnd[prev_level];
        int num_coarse    = coarse_end - coarse_start;
        int mc            = multiplier[prev_level];
        avtIntervalTree coarse_levels(num_coarse, dimension, false);
        double exts[6] = { 0, 0, 0, 0, 0, 0 };
        for (int i = 0 ; i < num_coarse ; i++)
        {
            exts[0] = mc*lowI[coarse_start+i];
            exts[1] = mc*hiI[coarse_start+i];
            exts[2] = mc*lowJ[coarse_start+i];
            exts[3] = mc*hiJ[coarse_start+i];
            if (dimension == 3)
            {
                exts[4] = mc*lowK[coarse_start+i];
                exts[5] = mc*hiK[coarse_start+i];
            }
            coarse_levels.AddElement(i, exts);
        }
        coarse_levels.Calculate(true);
        
hrchilds's avatar
hrchilds committed
1238
1239
        int patches_start = levelStart[level];
        int patches_end   = levelEnd[level];
1240
        int mp = multiplier[level];
hrchilds's avatar
hrchilds committed
1241
1242
        for (int patch = patches_start ; patch < patches_end ; patch++)
        {
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
            double min[3];
            double max[3];
            min[0] = mp*lowI[patch];
            max[0] = mp*hiI[patch];
            min[1] = mp*lowJ[patch];
            max[1] = mp*hiJ[patch];
            if (dimension == 3)
            {
                min[2] = mp*lowK[patch];
                max[2] = mp*hiK[patch];
            }
            vector<int> list;
            coarse_levels.GetElementsListFromRange(min, max, list);
            for (int i = 0 ; i < list.size() ; i++)
hrchilds's avatar
hrchilds committed
1257
            {
1258
1259
                int candidate = coarse_start + list[i];
                if (hiI[patch]*mp < lowI[candidate]*mc)
hrchilds's avatar
hrchilds committed
1260
                    continue;
1261
                if (lowI[patch]*mp >= hiI[candidate]*mc)
hrchilds's avatar
hrchilds committed
1262
                    continue;
1263
                if (hiJ[patch]*mp < lowJ[candidate]*mc)
hrchilds's avatar
hrchilds committed
1264
                    continue;
1265
                if (lowJ[patch]*mp >= hiJ[candidate]*mc)
hrchilds's avatar
hrchilds committed
1266
1267
1268
                    continue;
                if (dimension == 3)
                {
1269
                    if (hiK[patch]*mp < lowK[candidate]*mc)
hrchilds's avatar
hrchilds committed
1270
                        continue;
1271
                    if (lowK[patch]*mp >= hiK[candidate]*mc)
hrchilds's avatar
hrchilds committed
1272
1273
1274
1275
1276
1277
                        continue;
                }
                childPatches[candidate].push_back(patch);
           }
        }
    }
1278
    visitTimer->StopTimer(t3, "Slow part of Chombo nesting.");
hrchilds's avatar
hrchilds committed
1279
1280
1281
1282
1283

    //
    // Now that we know the extents for each patch and what its children are,
    // tell the structured domain boundary that information.
    //
1284
    int t4 = visitTimer->StartTimer();
hrchilds's avatar
hrchilds committed
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
    for (int i = 0 ; i < totalPatches ; i++)
    {
        int my_level, local_patch;
        GetLevelAndLocalPatchNumber(i, my_level, local_patch);

        vector<int> logExts(6);
        logExts[0] = lowI[i];
        logExts[3] = hiI[i]-1;
        logExts[1] = lowJ[i];
        logExts[4] = hiJ[i]-1;
        logExts[2] = 0;
        logExts[5] = 0;
        if (dimension == 3)
        {
            logExts[2] = lowK[i];
            logExts[5] = hiK[i]-1;
        }

        dn->SetNestingForDomain(i, my_level, childPatches[i], logExts);
    }

    //
    // Register this structure with the generic database so that it knows
    // to ghost out the right cells.
    //
    dn->SetNumDimensions(dimension);
    void_ref_ptr vr = void_ref_ptr(dn, avtStructuredDomainNesting::Destruct);
    cache->CacheVoidRef("any_mesh", AUXILIARY_DATA_DOMAIN_NESTING_INFORMATION,
                        timestep, -1, vr);
1314
    visitTimer->StopTimer(t4, "Final step of Chombo nesting");
hrchilds's avatar
hrchilds committed
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
}


// ****************************************************************************
//  Method: avtChomboFileFormat::PopulateDatabaseMetaData
//
//  Purpose:
//      This database meta-data object is like a table of contents for the
//      file.  By populating it, you are telling the rest of VisIt what
//      information it can request from you.
//
//  Programmer: childs -- generated by xml2avt
//  Creation:   Thu Jan 19 11:17:14 PDT 2006
//
hrchilds's avatar
hrchilds committed
1329
1330
1331
1332
1333
1334
//  Modifications:
//
//    Hank Childs, Mon Jun 19 14:30:12 PDT 2006
//    Fix problem with grouping vectors in 3D.  Also add support for U,V,W
//    vectors.
//
1335
1336
1337
1338
//    Gunther H. Weber, Tue Aug  7 16:00:22 PDT 2007
//    If material information was found in the file, add corresponding
//    meta data
//
1339
1340
1341
//    Gunther H. Weber, Thu Oct 11 15:49:41 PDT 2007
//    Add expressions from Chombo files.
//
hrchilds's avatar
hrchilds committed
1342
1343
1344
1345
//    Hank Childs, Sun Oct 28 09:42:50 PST 2007
//    Set meta-data saying whether or not we have ghosts on the exterior
//    boundary.
//
1346
1347
1348
//    Gunther H. Weber, Mon Mar 24 20:46:04 PDT 2008
//    Added support for node centered Chombo data.
//
1349
1350
1351
1352
//    Gunther H. Weber, Mon Mar 24 21:14:59 PDT 2008
//    Fixed bug for files containing only one level when "default to only root
//    level was selected" (for these files an empty selection was the result).
//
ghweber's avatar
ghweber committed
1353
//    Gunther H. Weber, Tue Apr 15 17:43:30 PDT 2008
ghweber's avatar
ghweber committed
1354
1355
1356
1357
1358
1359
//    Add support to automatically import a coordinate mapping file via
//    conn_cmfe.
//
//    Gunther H. Weber, Thu Apr 17 14:47:44 PDT 2008
//    Do not use a unique but unreadable name for displacement expression
//    since database-defined expressions are local to database.
ghweber's avatar
ghweber committed
1360
//
1361
1362
1363
//    Gunther H. Weber, Thu May  8 19:41:52 PDT 2008
//    Set spatial extents.
//
1364
1365
1366
//    Hank Childs, Sun Jan 25 15:55:17 PST 2009
//    Change test for whether or not we are using ghost data.
//
1367
1368
1369
//    Gunther H. Weber, Wed Jun 10 18:28:24 PDT 2009
//    Added ability to handle particle data in Chombo files.
//
1370
1371
1372
1373
//    Gunther H. Weber, Wed Jul 22 15:42:27 PDT 2009
//    Only set cycle in metadata if it can be determined. Otherwise announce
//    that it is not accurate.
//
1374
1375
1376
//    Gunther H. Weber, Tue Sep 15 11:26:12 PDT 2009
//    Added support for 3D mappings for 2D files.
//
hrchilds's avatar
hrchilds committed
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
// ****************************************************************************

void
avtChomboFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
{
    int   i, j;

    if (!initializedReader)
        InitializeReader();

    int totalPatches = 0;
    int level;
    for (level = 0 ; level < num_levels ; level++)
    {
        totalPatches += patchesPerLevel[level];
    }

    // Prevent VisIt from sorting the variables.
    md->SetMustAlphabetizeVariables(false);

    //
    // Set up the mesh.  Use the groups construct to represent refinement
    // levels.  Also take care to name each patch in an appropriate way.
    char mesh_name[32] = "Mesh";
    avtMeshMetaData *mesh = new avtMeshMetaData;
    mesh->name = mesh_name;
    mesh->meshType = AVT_AMR_MESH;
    mesh->numBlocks = totalPatches;
    mesh->blockOrigin = 0;
    mesh->spatialDimension = dimension;
    mesh->topologicalDimension = dimension;
1408
1409
1410
1411
    if (dimension == 2 && checkForMappingFile && mappingFileExists && mappingIs3D)
    {
        mesh->spatialDimension = 3;
    }
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
    mesh->hasSpatialExtents = true;
    mesh->minSpatialExtents[0] = lowProbI[0] * dx[0];
    mesh->maxSpatialExtents[0] = (hiProbI[0] + 1) * dx[0];
    mesh->minSpatialExtents[1] = lowProbJ[0] * dx[0];
    mesh->maxSpatialExtents[1] = (hiProbJ[0] + 1) * dx[0];
    if (dimension == 3)
    {
        mesh->minSpatialExtents[2] = lowProbK[0] * dx[0];
        mesh->maxSpatialExtents[2] = (hiProbK[0] + 1) * dx[0];
    }
hrchilds's avatar
hrchilds committed
1422
1423
1424
1425
1426
    mesh->blockTitle = "patches";
    mesh->blockPieceName = "patch";
    mesh->numGroups = num_levels;
    mesh->groupTitle = "levels";
    mesh->groupPieceName = "level";
1427
    mesh->containsExteriorBoundaryGhosts = allowedToUseGhosts && fileContainsGhosts;
hrchilds's avatar
hrchilds committed
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
    std::vector<int> groupIds(totalPatches);
    std::vector<string> blockPieceNames(totalPatches);
    for (i = 0 ; i < totalPatches ; i++)
    {
        char tmpName[128];
        int level, local_patch;
        GetLevelAndLocalPatchNumber(i, level, local_patch);
        groupIds[i] = level;
        sprintf(tmpName, "level%d,patch%d", level, local_patch);
        blockPieceNames[i] = tmpName;
    }
    mesh->blockNames = blockPieceNames;
    md->Add(mesh);
    md->AddGroupInformation(num_levels, totalPatches, groupIds);

    //
    // Add each scalar variable.
    //
    int nVars = varnames.size();
    for (i = 0; i < nVars; i++)
    {
1449
        AddScalarVarToMetaData(md, varnames[i], mesh_name, nodeCentered ? AVT_NODECENT : AVT_ZONECENT);
hrchilds's avatar
hrchilds committed
1450
1451
1452
1453
1454
1455
1456
    }

    //
    // Chombo has no vector variables.  But it clearly has some scalar
    // variables that should be combined into vectors.  Identify these and
    // make expressions for the vectors.
    //
1457
    std::list<std::string> addedExpressionNames;
hrchilds's avatar
hrchilds committed
1458
1459
1460
1461
1462
    for (i = 0; i < nVars; i++)
    {
        int id2 = -1;
        bool startsWithFirst = false;
        bool foundVector = false;
hrchilds's avatar
hrchilds committed
1463
1464
        if (varnames[i][0] == 'x' || varnames[i][0] == 'X' || 
            varnames[i][0] == 'u' || varnames[i][0] == 'U')
hrchilds's avatar
hrchilds committed
1465
        {
hrchilds's avatar
hrchilds committed
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
            char yChar = '\0', zChar = '\0';
            if (varnames[i][0] == 'x')
            {
                yChar = 'y';
                zChar = 'z';
            }
            else if (varnames[i][0] == 'X')
            {
                yChar = 'Y';
                zChar = 'Z';
            }
            else if (varnames[i][0] == 'u')
            {
                yChar = 'v';
                zChar = 'w';
            }
            else if (varnames[i][0] == 'U')
            {
                yChar = 'V';
                zChar = 'W';
            }

hrchilds's avatar
hrchilds committed
1488
            char yName[1024];
hrchilds's avatar
hrchilds committed
1489
            SNPRINTF(yName, 1024, "%c%s", yChar, varnames[i].c_str()+1);
hrchilds's avatar
hrchilds committed
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
            int matchY = -1;
            for (j = 0 ; j < nVars ; j++)
            {
                if (varnames[j] == yName)
                {
                    matchY = j;
                    break;
                }
            }
            if (matchY < 0)
                continue;
            if (dimension == 2)
            {
                Expression vec;
                const char *str = varnames[i].c_str()+1;
                while (*str != '\0' && !isalpha(*str))
                    str++;
                vec.SetName(str);
                char defn[1024];
                SNPRINTF(defn, 1024, "{<%s>, <%s>}", varnames[i].c_str(), yName);
                vec.SetDefinition(defn);
                vec.SetType(Expression::VectorMeshVar);
                md->AddExpression(&vec);
1513
                addedExpressionNames.push_back(str);
hrchilds's avatar
hrchilds committed
1514
1515
1516
1517
            }
            else
            {
                char zName[1024];
hrchilds's avatar
hrchilds committed
1518
                SNPRINTF(zName, 1024, "%c%s", zChar, varnames[i].c_str()+1);
hrchilds's avatar
hrchilds committed
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
                int matchZ = -1;
                for (j = 0 ; j < nVars ; j++)
                {
                    if (varnames[j] == zName)
                    {
                        matchZ = j;
                        break;
                    }
                }
                if (matchZ < 0)
                    continue;
                Expression vec;
                const char *str = varnames[i].c_str()+1;
                while (*str != '\0' && !isalpha(*str))
                    str++;
                vec.SetName(str);
                char defn[1024];
                SNPRINTF(defn, 1024, "{<%s>, <%s>, <%s>}", varnames[i].c_str(), 
                                                     yName,zName);
                vec.SetDefinition(defn);
                vec.SetType(Expression::VectorMeshVar);
                md->AddExpression(&vec);
1541
                addedExpressionNames.push_back(str);
hrchilds's avatar
hrchilds committed
1542
1543
1544
1545
            }
        }
    }

1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
    // Add particle mesh and vars if available
    if (hasParticles)
    {
        // Add particle mesh
        AddMeshToMetaData(md, string("particles"), AVT_POINT_MESH, 0, 1, 0, dimension, 0);

        for (std::vector<std::string>::iterator it = particleVarnames.begin();
                it != particleVarnames.end(); ++it)
        {
            AddScalarVarToMetaData(md, *it, std::string("particles"), AVT_NODECENT);
        }

        //
        // Chombo has no vector variables.  But it clearly has some scalar
        // variables that should be combined into vectors.  Identify these and
        // make expressions for the vectors.
        //
        for (i = 0; i < particleVarnames.size(); i++)
        {
            int id2 = -1;
            bool startsWithFirst = false;
            bool foundVector = false;
            size_t len = particleVarnames[i].size();
            if (particleVarnames[i][len-2] == '_' &&
                    (particleVarnames[i][len-1] == 'x' || particleVarnames[i][len-1] == 'X' ||
                     particleVarnames[i][len-1] == 'u' || particleVarnames[i][len-1] == 'U'))
            {
                char yChar = '\0', zChar = '\0';
                if (particleVarnames[i][len-1] == 'x')
                {
                    yChar = 'y';
                    zChar = 'z';
                }
                else if (particleVarnames[i][len-1] == 'X')
                {
                    yChar = 'Y';
                    zChar = 'Z';
                }
                else if (particleVarnames[i][len-1] == 'u')
                {
                    yChar = 'v';
                    zChar = 'w';
                }
                else if (particleVarnames[i][len-1] == 'U')
                {
                    yChar = 'V';
                    zChar = 'W';
                }

                std::string yName = particleVarnames[i];
                yName[len-1] = yChar;
                int matchY = -1;
                for (j = 0 ; j < particleVarnames.size() ; j++)
                {
                    if (particleVarnames[j] == yName)
                    {
                        matchY = j;
                        break;
                    }
                }
                if (matchY < 0)
                    continue;
                if (dimension == 2)
                {
                    Expression vec;
                    std::string expressionName(particleVarnames[i], 0, len-2);
                    if (std::find(addedExpressionNames.begin(), addedExpressionNames.end(),
                                expressionName) != addedExpressionNames.end())
                        expressionName.insert(0, std::string("particle_"));
                    vec.SetName(expressionName);
                    char defn[1024];
                    SNPRINTF(defn, 1024, "{<%s>, <%s>}", particleVarnames[i].c_str(), yName.c_str());
                    vec.SetDefinition(defn);
                    vec.SetType(Expression::VectorMeshVar);
                    md->AddExpression(&vec);
                }
                else
                {
                    std::string zName = particleVarnames[i];
                    zName[len-1] = zChar;
                    int matchZ = -1;
                    for (j = 0 ; j < particleVarnames.size() ; j++)
                    {
                        if (particleVarnames[j] == zName)
                        {
                            matchZ = j;
                            break;
                        }
                    }
                    if (matchZ < 0)
                        continue;
                    Expression vec;
                    std::string expressionName(particleVarnames[i], 0, len-2);
                    if (std::find(addedExpressionNames.begin(), addedExpressionNames.end(),
                                expressionName) != addedExpressionNames.end())
                        expressionName.insert(0, std::string("particle_"));
                    vec.SetName(expressionName);
                    char defn[1024];
                    SNPRINTF(defn, 1024, "{<%s>, <%s>, <%s>}", particleVarnames[i].c_str(), 
                            yName.c_str(), zName.c_str());
                    vec.SetDefinition(defn);
                    vec.SetType(Expression::VectorMeshVar);
                    md->AddExpression(&vec);
                }
            }
        }
    }
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
    //
    // If any materials were found, add them here
    // 
    if (nMaterials)
    {
        vector<string> mnames(nMaterials);

        string matname;
        matname = "materials";
        
        char str[32];
        for (int m = 0; m < nMaterials; ++m)
        {
            sprintf(str, "mat%d", m+1);
            mnames[m] = str;
        }
        AddMaterialToMetaData(md, matname, mesh_name, nMaterials, mnames);
    }

1672
1673
1674
1675
1676
1677
1678
1679
    //
    // If any expressions where found, add them here
    //
    for (std::list<Expression*>::iterator it = expressions.begin(); it != expressions.end(); ++it)
    {
        md->AddExpression(*it);
    }

ghweber's avatar
ghweber committed
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
    //
    // Check for existence of mapping file
    //
    if (checkForMappingFile)
    {
        std::string mappingFilename(filenames[0]);
        size_t extPos = mappingFilename.find(".hdf5");
        if  (extPos == std::string::npos)
        {
            extPos = mappingFilename.find(".h5");
        }

        if (extPos != std::string::npos)
        {
            mappingFilename.insert(extPos, ".map");

1696
            if (mappingFileExists)
ghweber's avatar
ghweber committed
1697
1698
            {
                debug5 << "Found mapping file " << mappingFilename << ". ";
ghweber's avatar
ghweber committed
1699
                debug5 << "Adding cmfe expression!" << std::endl;
ghweber's avatar
ghweber committed
1700

1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
#ifdef _WIN32
                // Escape ":" and "\" in Windows filenames
                int numCharactersToEscape = 0;
                for (std::string::iterator it = mappingFilename.begin();
                        it != mappingFilename.end(); ++it)
                    if (*it == ':' || *it == '\\')
                        ++numCharactersToEscape;

                if (numCharactersToEscape)
                {
                    std::string escapedFilename;
                    for (std::string::iterator it = mappingFilename.begin();
                            it != mappingFilename.end(); ++it)
                    {
                        if (*it == ':' || *it == '\\')
                            escapedFilename.push_back('\\');
                        escapedFilename.push_back(*it);
                    }
                    mappingFilename = escapedFilename; 
                }
#endif

ghweber's avatar
ghweber committed
1723
                Expression *mappingExpression = new Expression;
ghweber's avatar
ghweber committed
1724
1725
                //mappingExpression->SetName("_"+mappingVarPrefix+"_disp");
                mappingExpression->SetName("_mapping_displacement");
ghweber's avatar
ghweber committed
1726
1727
1728
                mappingExpression->SetType(Expression::VectorMeshVar);
                mappingExpression->SetHidden(false);

1729
                if (dimension == 2 && !mappingIs3D)
ghweber's avatar
ghweber committed
1730
1731
1732
1733
1734