# AvtStructuredDomainNesting

The avtStructuredDomainNesting is the module that describes the nesting relationship between AMR patches. This page describes its interface, both how to generate this data structure and how to use it.

## Functions for setting up an avtStructuredDomainNesting

### Constructor

```     avtStructuredDomainNesting *dn = new avtStructuredDomainNesting(
totalPatches, nLevels);
```

The first argument is the total number of patches.

#### Example

So if you had an AMR mesh with 2 levels, and the first level had 3 patches and the second level had 12 patches, then totalPatches would be 15 and nLevels would be 2.

### SetNumDimensions

You need to tell the data structure the number of dimensions (2D or 3D) with this call.

#### Example

```    domainNestingObject->SetNumDimensions(2);
```

### SetLevelRefinementRatios

This lets you specify the refinement ratio from level to level. Note that it is assumed that the refinement ratio is fixed from level to level.

#### Example

Assume you have a two dimensional AMR mesh with 3 levels. From level 0 to level 1, the refinement ratio is 2:1 in I and 3:1 in J. From level 1 to level 2, the refinement ratio is 4:1 in I and 5:1 in J.

Then you would have:

```  vector<int> rr(2);
rr[0] = 2;
rr[1] = 3;
domainNestingObject->SetLevelRefinementRatios(1, rr);
rr[0] = 4;
rr[1] = 5;
domainNestingObject->SetLevelRefinementRatios(2, rr);
```

### SettingNestingForDomain

This is called once for each domain. It declares what refinement level the domain is at, the extents for the domain (with respect to the indexing scheme at its level), which patches at a lower refinement level lie within this domain, and what their overlap are.

#### Example

• The mesh is two dimensional.
• We have three refinement levels.
• Each refinement level is a 2:1 refinement in I and J.
• The logical indexing for refinement level 0 goes from 0-9 in I and 0-9 in J.
• This determines the logical indexing for refinement levels 1 and 2.
• Refinement level 1 goes from 0-19 in I and J.
• Refinement level 2 goes from 0-39 in I and J.
• We have 4 patches.
• Patch 0 is at refinement level 0 and has indices from 0-9 in I and 0-9 in J.
• Patch 1 is at refinement level 1 and has indices 10-19 in I and 4-13 in J.
• Patch 2 is at refinement level 2 and has indices 20-29 in I and 8-27 in J.
• Patch 3 is at refinement level 2 and has indices 30-39 in I and 8-27 in J.
• Observations:
• Patches 2,3 completely cover patch 1 in this example so you can't see patch 1 in the plots of this AMR mesh.
• Each patch refines a patch at exactly one coarser refinement level.
• When a patch is at level K, it is sitting within a patch at level K-1, which is sitting within a patch at level K-2, etc.
• It is never the case that a patch at level K sits directly within a patch at level K-2 without a level K-1 patch in between.
• When a coarse patch is refined by a finer patch, it is not possible for a cell in the coarser patch to be partially refined.
• Each cell in the coarser patch must be completed refined away or not at all.
• For example, patch 1 could not go from 1-1 in I and 0-1 in J, as that would only cover one half of the I-dimensions of patch 0's cell.

Then we would call:

```   vector<int> childPatches;
vector<int> logExts;
logExts[0] = 0;  // Note weird ordering here
logExts[3] = 9;
logExts[1] = 0;
logExts[4] = 9;
logExts[2] = logExts[5] = 0;
childPatches.push_back(1);
domainNestingObject->SetNestingForDomain(0, 0, childsPatches, logExts);
logExts[0] = 10;
logExts[3] = 19;
logExts[1] = 4;
logExts[4] = 13;
logExts[2] = logExts[5] = 0;
childPatches.clear();
childPatches.push_back(2);
childPatches.push_back(3);
domainNestingObject->SetNestingForDomain(1, 1, childsPatches, logExts);
logExts[0] = 20;
logExts[3] = 29;
logExts[1] = 8;
logExts[4] = 27;
logExts[2] = logExts[5] = 0;
childPatches.clear();
domainNestingObject->SetNestingForDomain(2, 2, childsPatches, logExts);
logExts[0] = 30;
logExts[3] = 39;
logExts[1] = 8;
logExts[4] = 27;
logExts[2] = logExts[5] = 0;
childPatches.clear();
domainNestingObject->SetNestingForDomain(3, 2, childsPatches, logExts);
```

## Functions for getting information from an avtStructuredDomainNesting

Basically, the only method you can use to get information is GetNestingForDomain. This is probably because this method has only been used for setting up ghost data (to date). (If you think you need a new method, you are probably right.)

### GetNestingForDomain

With this method, you give a domain identifier and it returns the logical extents of that domain, which patches refine portions of that domain, and the overlap (in terms of logical extents) of each refinement.

#### Example

• The mesh is two dimensional.
• We have three refinement levels.
• Each refinement level is a 2:1 refinement in I and J.
• The logical indexing for refinement level 0 goes from 0-9 in I and 0-9 in J.
• This determines the logical indexing for refinement levels 1 and 2.
• Refinement level 1 goes from 0-19 in I and J.
• Refinement level 2 goes from 0-39 in I and J.
• We have 4 patches.
• Patch 0 is at refinement level 0 and has indices from 0-9 in I and 0-9 in J.
• Patch 1 is at refinement level 1 and has indices 10-19 in I and 4-13 in J.
• Patch 2 is at refinement level 2 and has indices 20-29 in I and 8-27 in J.
• Patch 3 is at refinement level 2 and has indices 30-39 in I and 8-27 in J.

Then

```   domainNestingObject->GetNestingForDomain(0, exts, childDomains, childExts);
```

would return exts = {0, 0, 0, 9, 9, 0}, childDomains = {1}, and childExts = {5, 0, 0, 9, 9, 0}.