Chombo + EB  3.2
IFSlicerImplem.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _IFSLICERIMPLEM_H_
12 #define _IFSLICERIMPLEM_H_
13 
14 #include <iostream>
15 
16 #include "NamespaceHeader.H"
17 
18 // empty constructor
19 template <int dim> IFSlicer<dim>::IFSlicer()
20 {
21  //set to undefined values
22  m_IFSlicer = NULL;
23  m_fixedComp = LARGEINTVAL;
24  m_fixedValue = LARGEREALVAL;
25 }
26 
27 //copy constructor
28 template <int dim >IFSlicer<dim>::IFSlicer(const IFSlicer<dim> & a_IFSlicer)
29 {
30  setParams(a_IFSlicer.m_IFSlicer,
31  a_IFSlicer.m_fixedComp,
32  a_IFSlicer.m_fixedValue);
33 }
34 
35 template <int dim> IFSlicer<dim>::IFSlicer(IFSlicer<dim+1> const * a_IFSlicer,
36  const int & a_fixedComp,
37  const Real & a_fixedValue)
38 {
39  setParams(a_IFSlicer,
40  a_fixedComp,
41  a_fixedValue);
42 }
43 
44 template <int dim> void IFSlicer<dim>::setParams(IFSlicer<dim+1> const * a_IFSlicer,
45  const int & a_fixedComp,
46  const Real & a_fixedValue)
47 {
48  // copy the inputs
49  m_IFSlicer = a_IFSlicer;
50  m_fixedComp = a_fixedComp;
51  m_fixedValue = a_fixedValue;
52 }
53 
54 // Destructor
55 template <int dim> IFSlicer<dim>::~IFSlicer()
56 {
57  //lower dimension doesn't own the objects referred to by any pointer.
58 }
59 
60 template<int dim >Real IFSlicer<dim>::value(const IndexTM<int, dim> & a_partialDerivative,
61  const IndexTM<Real,dim> & a_point) const
62 {
63  Real retval = LARGEREALVAL;
64 
65  //use fixedComp and fixedValue to pull partialDerivative and point into one higher dimension
66  IndexTM<int, dim + 1> partialDerivative;
68  for (int idir = 0; idir < dim +1; ++idir)
69  {
70  if (idir < m_fixedComp)
71  {
72  partialDerivative[idir] = a_partialDerivative[idir];
73  point [idir] = a_point [idir];
74  }
75  else if (idir > m_fixedComp)
76  {
77  partialDerivative[idir] = a_partialDerivative[idir - 1];
78  point [idir] = a_point [idir - 1];
79  }
80  else
81  {
82  partialDerivative[m_fixedComp] = 0;
83  point [m_fixedComp] = m_fixedValue;
84  }
85  }
86 
87  //evaluate at one higher dimension
88  retval = m_IFSlicer->value(partialDerivative,point);
89 
90  return retval;
91 }
92 
93 template <int dim> void IFSlicer<dim>::print(ostream& a_out) const
94 {
95  a_out << "fixed component = " << m_fixedComp << "\n";
96  a_out << "fixed value = " << m_fixedValue << "\n";
97  a_out << "At one dimension higher: " << dim + 1 << "\n";
98  this->m_IFSlicer.print(a_out);
99 }
100 
101 template <int dim> ostream& operator<<(ostream & a_out,
102  const IFSlicer<dim> & a_IFSlicer)
103 {
104  a_IFSlicer.print(a_out);
105  return a_out;
106 }
107 
108 #include "NamespaceFooter.H"
109 
110 #endif
#define LARGEREALVAL
Definition: Notation.H:77
void setParams(IFSlicer< dim+1 > const *a_slicer, const int &a_fixedComp, const Real &a_fixedValue)
Definition: IFSlicerImplem.H:44
void print(ostream &out) const
output function
Definition: IFSlicerImplem.H:93
#define LARGEINTVAL
Definition: Notation.H:76
int m_fixedComp
Definition: IFSlicer.H:80
IFSlicer< dim+1 > const * m_IFSlicer
Definition: IFSlicer.H:77
ostream & operator<<(ostream &a_out, const IFSlicer< dim > &a_IFSlicer)
Definition: IFSlicerImplem.H:101
Definition: IndexTM.H:36
Real m_fixedValue
Definition: IFSlicer.H:81
IFSlicer()
null constructor
Definition: IFSlicerImplem.H:19
double Real
Definition: REAL.H:33
virtual Real value(const IndexTM< int, dim > &a_partialDerivative, const IndexTM< Real, dim > &a_point) const
Return the partial derivative evaluated at a_point.
Definition: IFSlicerImplem.H:60
Definition: IFSlicer.H:27
virtual ~IFSlicer()
destructor
Definition: IFSlicerImplem.H:55
int dim
Definition: EBInterface.H:146