PlasCom2  1.0
XPACC Multi-physics simluation application
RKTestFixtures.H
Go to the documentation of this file.
1 #ifndef __RK_TEST_FIXTURES_H__
2 #define __RK_TEST_FIXTURES_H__
3 
4 #include "Simulation.H"
5 
7 
8 template<typename DomainT>
9 class testrhs : public DomainT::RHSType {
10 public:
11  typedef typename DomainT::GridType GridType;
12  typedef typename DomainT::StateType StateType;
13  typedef typename DomainT::OperatorType OperatorType;
14 public:
15  static double TestF(double time,int order){
16  return(std::pow(time,static_cast<double>(order)));
17  };
18 
19  static double RHSF(double inTime,int inOrder)
20  {
21  double coeff = static_cast<double>(inOrder);
22  double timePow = std::pow(inTime,static_cast<double>(inOrder-1));
23  return(coeff*timePow);
24  };
25 
26  virtual int SetupRHS(GridType &inGrid,StateType &inState,StateType &rhsState,int myThreadId = 0)
27  {
28  myGrid = &inGrid;
29  myState = &inState;
30  myRHSState = &rhsState;
31  myDT = 0;
32  return(0);
33  };
34  void SetTimestep(double inDT) { myDT = inDT; };
35  virtual int Initialize(GridType &inGrid,StateType &inState)
36  { return(0);};
37  virtual int RHS(int threadId = 0)
38  {
40  };
41  virtual int ProcessInterior2(GridType &inGrid,StateType &inState,StateType &rhsState)
42  { return(0); };
43  virtual int ProcessInterior(GridType &inGrid,StateType &inState,StateType &rhsState,int threadId = 1)
44  {
45 
46  pcpp::field::dataset::DataBufferType &timeData(inState.Field("simTime"));
47  double *inTime = timeData.Data<double>();
48 
49  pcpp::field::dataset::DataBufferType &aData(inState.Field("A"));
50  double *inA = aData.Data<double>();
51 
52  std::cout << "testrhs::ProcessInterior: Time = " << *inTime << std::endl;
53  std::cout << "testrhs::ProcessInterior: A = " << *inA << std::endl;
54  std::cout << "testrhs::Address of time: " << inTime << std::endl;
55 
56  double *outF0 = rhsState.GetStateFieldData("F0");
57  double *outF1 = rhsState.GetStateFieldData("F1");
58  double *outF2 = rhsState.GetStateFieldData("F2");
59  double *outF3 = rhsState.GetStateFieldData("F3");
60  double *outF4 = rhsState.GetStateFieldData("F4");
61  double *outF5 = rhsState.GetStateFieldData("F5");
62  double *outF6 = rhsState.GetStateFieldData("F6");
63 
64  *outF0 = *inA*RHSF(*inTime,0);
65  *outF1 = *inA*RHSF(*inTime,1);
66  *outF2 = *inA*RHSF(*inTime,2);
67  *outF3 = *inA*RHSF(*inTime,3);
68  *outF4 = *inA*RHSF(*inTime,4);
69  *outF5 = *inA*RHSF(*inTime,5);
70  *outF6 = *inA*RHSF(*inTime,6);
71 
72  std::cout << "testrhs::Out0 = " << *outF0 << std::endl
73  << "testrhs::Out1 = " << *outF1 << std::endl
74  << "testrhs::Out2 = " << *outF2 << std::endl
75  << "testrhs::Out3 = " << *outF3 << std::endl
76  << "testrhs::Out4 = " << *outF4 << std::endl
77  << "testrhs::Out5 = " << *outF5 << std::endl
78  << "testrhs::Out6 = " << *outF6 << std::endl;
79 
80  return(0);
81  };
82  virtual double TimeStep(double *inCFL = NULL) { return(myDT); };
83  virtual int ProcessHalo(halo_t &inHalo,GridType &inGrid,StateType &inState,StateType &rhsState,int threadId = 1)
84  { return(0); };
85  virtual int ProcessBoundary(GridType &inGrid,StateType &inState,StateType &rhsState,int threadId = 1)
86  { return(0); };
87 protected:
88  StateType *myState;
89  StateType *myRHSState;
90  GridType *myGrid;
91  double myDT;
92 };
93 
94 //typedef testrhs RHSHandlerType;
95 
96 #endif
StateType * myRHSState
virtual int SetupRHS(GridType &inGrid, StateType &inState, StateType &rhsState, int myThreadId=0)
static double RHSF(double inTime, int inOrder)
virtual int ProcessHalo(halo_t &inHalo, GridType &inGrid, StateType &inState, StateType &rhsState, int threadId=1)
virtual int ProcessInterior(GridType &inGrid, StateType &inState, StateType &rhsState, int threadId=1)
static double TestF(double time, int order)
DomainT::StateType StateType
DomainT::GridType GridType
virtual int ProcessBoundary(GridType &inGrid, StateType &inState, StateType &rhsState, int threadId=1)
simulation::grid::halo halo_t
Definition: RKTestFixtures.H:6
GridType * myGrid
virtual int Initialize(GridType &inGrid, StateType &inState)
virtual int RHS(int threadId=0)
double myDT
StateType * myState
void SetTimestep(double inDT)
virtual double TimeStep(double *inCFL=NULL)
DomainT::OperatorType OperatorType
virtual int ProcessInterior2(GridType &inGrid, StateType &inState, StateType &rhsState)