@@ -59,6 +59,7 @@ CSchemeGodunov::CSchemeGodunov(void)
5959 this ->ulReductionGlobalSize = 0 ;
6060 this ->ulReductionWorkgroupSize = 0 ;
6161 this ->dAvgTimestep = 0.0 ;
62+ this ->sum_deficit_bilan = 0.0 ;
6263
6364 this ->dCurrentTime = 0.0 ;
6465 this ->dCurrentTimestepMovAvg = 0.0 ;
@@ -572,10 +573,14 @@ void CSchemeGodunov::prepare1OMemory(){
572573 this ->oclBufferCellManning = new COCLBuffer (" Manning coefficients" , oclModel, true , true );
573574 if (this ->bUseOptimizedBoundary == false ) {
574575 this ->oclBufferCellBoundary = new COCLBuffer (" Boundary Values" , oclModel, false , true );
576+ this ->oclBufferBilanDef = new COCLBuffer (" BilanDef" , oclModel, false , true );
577+ this ->sum_deficit_bilan = 0.0 ;
575578 }
576579 else {
577580 this ->oclBufferCouplingIDs = new COCLBuffer (" Coupling IDs" , oclModel, true , true );
578581 this ->oclBufferCouplingValues = new COCLBuffer (" Coupling Values" , oclModel, false , true );
582+ this ->oclBufferBilanDef = new COCLBuffer (" BilanDef" , oclModel, false , true );
583+ this ->sum_deficit_bilan = 0.0 ;
579584 }
580585 this ->oclBufferUsePoleni = new COCLBuffer (" Poleni Booleans" , oclModel, true , true );
581586 this ->oclBuffer_opt_zxmax = new COCLBuffer (" opt_zxmax Values" , oclModel, true , true );
@@ -584,15 +589,19 @@ void CSchemeGodunov::prepare1OMemory(){
584589 this ->oclBuffer_opt_cy = new COCLBuffer (" opt_cy Values" , oclModel, true , true );
585590 this ->oclBufferCellBed = new COCLBuffer (" Bed elevations" , oclModel, true , true );
586591
592+
593+
587594 this ->oclBufferCellStates ->setPointer (pCellStates, ucFloatSize * 4 * pDomain->getCellCount ());
588595 this ->oclBufferCellStatesAlt ->setPointer (pCellStates, ucFloatSize * 4 * pDomain->getCellCount ());
589596 this ->oclBufferCellManning ->setPointer (pManningValues, ucFloatSize * pDomain->getCellCount ());
590597 if (this ->bUseOptimizedBoundary == false ) {
591598 this ->oclBufferCellBoundary ->setPointer (pBoundaryValues, ucFloatSize * pDomain->getCellCount ());
599+ this ->oclBufferBilanDef ->setPointer (pBoundaryValues, ucFloatSize * pDomain->getCellCount ());
592600 }
593601 else {
594602 this ->oclBufferCouplingIDs ->setPointer (pCouplingIDs, sizeof (cl_ulong) * this ->ulCouplingArraySize );
595603 this ->oclBufferCouplingValues ->setPointer (pCouplingValues, ucFloatSize * this ->ulCouplingArraySize );
604+ this ->oclBufferBilanDef ->setPointer (pCouplingValues, ucFloatSize * this ->ulCouplingArraySize );
596605 }
597606 this ->oclBufferUsePoleni ->setPointer (pPoleniValues, sizeof (sUsePoleni ) * pDomain->getCellCount ());
598607 this ->oclBuffer_opt_zxmax ->setPointer (pOpt_zxmax, ucFloatSize * pDomain->getCellCount ());
@@ -606,10 +615,12 @@ void CSchemeGodunov::prepare1OMemory(){
606615 this ->oclBufferCellManning ->createBuffer ();
607616 if (this ->bUseOptimizedBoundary == false ) {
608617 this ->oclBufferCellBoundary ->createBuffer ();
618+ this ->oclBufferBilanDef ->createBuffer ();
609619 }
610620 else {
611621 this ->oclBufferCouplingIDs ->createBuffer ();
612622 this ->oclBufferCouplingValues ->createBuffer ();
623+ this ->oclBufferBilanDef ->createBuffer ();
613624 }
614625 this ->oclBufferUsePoleni ->createBuffer ();
615626 this ->oclBuffer_opt_zxmax ->createBuffer ();
@@ -628,7 +639,7 @@ void CSchemeGodunov::prepare1OMemory(){
628639 this ->oclBufferTimeTarget = new COCLBuffer (" Target time (sync)" , oclModel, false , true , ucFloatSize, true );
629640 this ->oclBufferTimestepMovAvg = new COCLBuffer (" Timestep Moving Average" , oclModel, false , true , ucFloatSize, true );
630641 this ->oclBufferTimeHydrological = new COCLBuffer (" Time (hydrological)" , oclModel, false , true , ucFloatSize, true );
631- this -> oclBufferBilanDef = new COCLBuffer ( " BilanDef " , oclModel, false , true , ucFloatSize, true );
642+
632643
633644 // We duplicate the time and timestep variables if we're using single-precision so we have copies in both formats
634645 if (cModel->getFloatPrecision () == model::floatPrecision::kSingle )
@@ -638,23 +649,23 @@ void CSchemeGodunov::prepare1OMemory(){
638649 *(this ->oclBufferTimestepMovAvg ->getHostBlock <float *>()) = 0 .0f ;
639650 *(this ->oclBufferTimeHydrological ->getHostBlock <float *>()) = 0 .0f ;
640651 *(this ->oclBufferTimeTarget ->getHostBlock <float *>()) = 0 .0f ;
641- *( this -> oclBufferBilanDef -> getHostBlock < float *>()) = 0 . 0f ;
652+
642653 }
643654 else {
644655 *(this ->oclBufferTime ->getHostBlock <double *>()) = this ->dCurrentTime ;
645656 *(this ->oclBufferTimestep ->getHostBlock <double *>()) = this ->dCurrentTimestep ;
646657 *(this ->oclBufferTimestepMovAvg ->getHostBlock <double *>()) = 0.0 ;
647658 *(this ->oclBufferTimeHydrological ->getHostBlock <double *>()) = 0.0 ;
648659 *(this ->oclBufferTimeTarget ->getHostBlock <double *>()) = 0.0 ;
649- *( this -> oclBufferBilanDef -> getHostBlock < double *>()) = 0.0 ;
660+
650661 }
651662 // create the buffers
652663 this ->oclBufferTimestep ->createBuffer ();
653664 this ->oclBufferTime ->createBuffer ();
654665 this ->oclBufferTimestepMovAvg ->createBuffer ();
655666 this ->oclBufferTimeHydrological ->createBuffer ();
656667 this ->oclBufferTimeTarget ->createBuffer ();
657- this -> oclBufferBilanDef -> createBuffer ();
668+
658669
659670 // --
660671 // Timestep reduction global array
@@ -791,6 +802,7 @@ void CSchemeGodunov::release1OResources()
791802 if (this ->oclBufferCellBoundary != NULL ) delete oclBufferCellBoundary;
792803 if (this ->oclBufferCouplingIDs != NULL ) delete oclBufferCouplingIDs;
793804 if (this ->oclBufferCouplingValues != NULL ) delete oclBufferCouplingValues;
805+ if (this ->oclBufferBilanDef != NULL ) delete this ->oclBufferBilanDef ;
794806 if (this ->oclBufferUsePoleni != NULL ) delete oclBufferUsePoleni;
795807 if (this ->oclBuffer_opt_zxmax != NULL ) delete oclBuffer_opt_zxmax;
796808 if (this ->oclBuffer_opt_cx != NULL ) delete oclBuffer_opt_cx;
@@ -820,6 +832,7 @@ void CSchemeGodunov::release1OResources()
820832 oclBufferCellBoundary = NULL ;
821833 oclBufferCouplingIDs = NULL ;
822834 oclBufferCouplingValues = NULL ;
835+ this ->oclBufferBilanDef = NULL ;
823836 oclBufferUsePoleni = NULL ;
824837 oclBuffer_opt_zxmax = NULL ;
825838 oclBuffer_opt_cx = NULL ;
@@ -853,10 +866,12 @@ void CSchemeGodunov::prepareSimulation()
853866 oclBufferCellManning->queueWriteAll ();
854867 if (this ->bUseOptimizedBoundary == false ) {
855868 oclBufferCellBoundary->queueWriteAll ();
869+ this ->oclBufferBilanDef ->queueWriteAll ();
856870 }
857871 else {
858872 oclBufferCouplingIDs->queueWriteAll ();
859873 oclBufferCouplingValues->queueWriteAll ();
874+ this ->oclBufferBilanDef ->queueWriteAll ();
860875 }
861876 oclBufferUsePoleni->queueWriteAll ();
862877 oclBuffer_opt_zxmax->queueWriteAll ();
@@ -867,7 +882,7 @@ void CSchemeGodunov::prepareSimulation()
867882 oclBufferTimestep->queueWriteAll ();
868883 oclBufferTimestepMovAvg->queueWriteAll ();
869884 oclBufferTimeHydrological->queueWriteAll ();
870- this -> oclBufferBilanDef -> queueWriteAll ();
885+
871886
872887 this ->pDomain ->getDevice ()->blockUntilFinished ();
873888
@@ -1036,7 +1051,7 @@ void CSchemeGodunov::Threaded_runBatch()
10361051 if (this ->dCurrentTime < dTargetTime - 1e-8 ) {
10371052 oclKernelResetCounters->scheduleExecution ();
10381053 for (unsigned int i = 0 ; i < uiQueueAmount; i++) {
1039-
1054+ // /here the clacluation is started
10401055 this ->scheduleIteration ();
10411056 uiIterationsSinceTargetChanged++;
10421057 ulCurrentCellsCalculated += this ->pDomain ->getCellCount ();
@@ -1052,7 +1067,56 @@ void CSchemeGodunov::Threaded_runBatch()
10521067 oclBufferBatchSkipped->queueReadAll ();
10531068 oclBufferBatchSuccessful->queueReadAll ();
10541069 oclBufferBatchTimesteps->queueReadAll ();
1055- this ->oclBufferBilanDef ->queueReadAll ();
1070+ this ->sum_deficit_bilan = 0.0 ;
1071+ if (this ->bUseOptimizedBoundary == false ) {
1072+ this ->oclBufferBilanDef ->queueReadAll ();
1073+ for (int i = 0 ; i < pDomain->getCellCount ();i++) {
1074+ if (cModel->getFloatPrecision () == model::floatPrecision::kSingle )
1075+ {
1076+ float * data = (this ->oclBufferBilanDef ->getHostBlock <float *>());
1077+
1078+ this ->sum_deficit_bilan = this ->sum_deficit_bilan +data[i];
1079+
1080+ }
1081+ else {
1082+
1083+ double * data = (this ->oclBufferBilanDef ->getHostBlock <double *>());
1084+
1085+ this ->sum_deficit_bilan = this ->sum_deficit_bilan +data[i];
1086+
1087+ }
1088+
1089+
1090+
1091+ }
1092+
1093+
1094+
1095+ }
1096+ else {
1097+ this ->oclBufferBilanDef ->queueReadAll ();
1098+ for (int i = 0 ; i < this ->ulCouplingArraySize ; i++) {
1099+ if (cModel->getFloatPrecision () == model::floatPrecision::kSingle )
1100+ {
1101+ float * data = (this ->oclBufferBilanDef ->getHostBlock <float *>());
1102+
1103+ this ->sum_deficit_bilan = this ->sum_deficit_bilan + data[i];
1104+
1105+ }
1106+ else {
1107+
1108+ double * data = (this ->oclBufferBilanDef ->getHostBlock <double *>());
1109+
1110+ this ->sum_deficit_bilan = this ->sum_deficit_bilan + data[i];
1111+
1112+ }
1113+
1114+
1115+ }
1116+ }
1117+
1118+
1119+
10561120
10571121 this ->pDomain ->getDevice ()->blockUntilFinished ();
10581122
@@ -1082,7 +1146,7 @@ void CSchemeGodunov::Threaded_runBatch()
10821146 this ->bThreadTerminated = true ;
10831147}
10841148
1085- // Runs the actual simulation until completion or error
1149+ // Runs the actual simulation until completion or error here the simulation is set together via the kernels this connects the clc-methods as kernels
10861150void CSchemeGodunov::scheduleIteration () {
10871151 // std::cout << "start iteration" << std::endl;
10881152 COCLBuffer* bufferSrc = NULL ;
@@ -1106,6 +1170,7 @@ void CSchemeGodunov::scheduleIteration() {
11061170 oclKernelTimestepReduction->assignArgument (0 , bufferDst);
11071171
11081172 profiless
1173+ // here the timesteps is claculated depending to the scheme, e.g. function pro_cacheDisabled in CLSchemePromaides.clc/.h
11091174 oclKernelFullTimestep->scheduleExecution ();
11101175 profilese
11111176
@@ -1115,11 +1180,14 @@ void CSchemeGodunov::scheduleIteration() {
11151180 }
11161181
11171182 profilebs
1183+ // here the´bounadries are set e.g. function pro_cacheDisabled in CLSchemePromaides.clc/.h
11181184 oclKernelBoundary->scheduleExecution ();
11191185 profilebe
11201186
11211187 profilers
1122- if (this ->bDynamicTimestep ) { oclKernelTimestepReduction->scheduleExecution (); }
1188+ if (this ->bDynamicTimestep ) {
1189+ oclKernelTimestepReduction->scheduleExecution ();
1190+ }
11231191 profilere
11241192
11251193 profilets
@@ -1220,15 +1288,7 @@ void CSchemeGodunov::setDebugger(unsigned int debugX, unsigned int debugY) {
12201288// Function to get the bilan deficit
12211289double CSchemeGodunov::get_bilan_deficit (void ) {
12221290 if (this ->oclBufferBilanDef != NULL ) {
1223-
1224-
1225- if (cModel->getFloatPrecision () == model::floatPrecision::kSingle )
1226- {
1227- return *(this ->oclBufferBilanDef ->getHostBlock <float *>());
1228- }
1229- else {
1230- return *(this ->oclBufferBilanDef ->getHostBlock <double *>());
1231- }
1291+ return this ->sum_deficit_bilan ;
12321292 }
12331293 else {
12341294 return 0.0 ;
0 commit comments