CG  Version 25
sm/src/boundaryMacros.h
Go to the documentation of this file.
1 // ===================================================================================
2 // This macro extracts the boundary data arrays
3 // ===================================================================================
4 #beginMacro extractBoundaryDataArrays()
5  int pdbc[2*3*2*3];
6  #define dbc(s,a,side,axis) (pdbc[(s)+2*((a)+3*((side)+2*(axis)))])
8  #define addBoundaryForcing(side,axis) (pAddBoundaryForcing[(side)+2*(axis)])
9  real *pbcf[2][3];
10  // long int pbcfOffset[6];
11  // We need an 8 byte integer so we can pass to fortran: int64_t is in stdint.h
12  int64_t pbcfOffset[6];
13  #define bcfOffset(side,axis) pbcfOffset[(side)+2*(axis)]
14  for( int axis=0; axis<=2; axis++ )
15  {
16  for( int side=0; side<=1; side++ )
17  {
18  // *** for now make sure the boundary data array is allocated on all sides
19  if( ( pBoundaryData[side][axis]==NULL || parameters.isAdaptiveGridProblem() ) &&
20  mg.boundaryCondition(side,axis)>0 )
21  {
22  parameters.getBoundaryData(side,axis,grid,mg);
23  // RealArray & bd = *pBoundaryData[side][axis]; // this is now done in the above line *wdh* 090819
24  // bd=0.;
25  }
26 
27  if( pBoundaryData[side][axis]!=NULL )
28  {
29  if( debug & 8 )
30  printP("+++ Cgsm: add boundary forcing to (side,axis,grid)=(%i,%i,%i) useConservative=%i\n",side,axis,grid,
31  (int)useConservative);
32 
34  RealArray & bd = *pBoundaryData[side][axis];
35  pbcf[side][axis] = bd.getDataPointer();
36 
37  // if( debug & 8 )
38  // ::display(bd," ++++ Cgsm: Here is bd ++++","%4.2f ");
39 
40 
41  for( int a=0; a<=2; a++ )
42  {
43  dbc(0,a,side,axis)=bd.getBase(a);
44  dbc(1,a,side,axis)=bd.getBound(a);
45  }
46  }
47  else
48  {
50  pbcf[side][axis] = fptr; // should not be used in this case
51  for( int a=0; a<=2; a++ )
52  {
53  dbc(0,a,side,axis)=0;
54  dbc(1,a,side,axis)=0;
55  }
56  }
57 
58  // for now we save the offset in a 4 byte int (double check that this is ok)
59  int64_t offset = pbcf[side][axis]- pbcf[0][0];
60 // if( offset > INT_MAX )
61 // {
62 // printF("ERROR: offset=%li INT_MAX=%li \n",offset,(long int)INT_MAX);
63 // }
64 // assert( offset < INT_MAX );
65  bcfOffset(side,axis) = offset;
66  // bcfOffset(side,axis) = pbcf[side][axis]- pbcf[0][0];
67 
68  // cout << " **** bcfOffset= " << bcfOffset(side,axis) << endl;
69 
70 
71  }
72  }
73 #endMacro
74 
75 // ===============================================================================================
76 // This macro determines the pointers to the variable material properties that are
77 // used when calling fortran routines.
78 // ===============================================================================================
79 #beginMacro getVariableMaterialPropertyPointers(defaultMatIndexPtr,defaultMatValPtr)
80 
81  // --- Variable material properies ---
83  int ndMatProp=1; // for piecewise constant materials, this is the leading dimension of the matVal array
84  int *matIndexPtr=defaultMatIndexPtr; // if not used, point to mask
85  real*matValPtr=defaultMatValPtr; // if not used, point to u
86  if( parameters.dbase.get<int>("variableMaterialPropertiesOption")!=0 )
87  {
88  // Material properties do vary
89  std::vector<GridMaterialProperties> & materialProperties =
90  parameters.dbase.get<std::vector<GridMaterialProperties> >("materialProperties");
91 
92  GridMaterialProperties & matProp = materialProperties[grid];
93  materialFormat = matProp.getMaterialFormat();
94 
96  {
97  IntegerArray & matIndex = matProp.getMaterialIndexArray();
98  matIndexPtr = matIndex.getDataPointer();
99  }
100 
101  RealArray & matVal = matProp.getMaterialValuesArray();
102  matValPtr = matVal.getDataPointer();
103  ndMatProp = matVal.getLength(0);
104 
105 
106  // ::display(matVal,"matVal");
107  }
108 #endMacro