void mutex_bench(void) { u32_t mutex_lock_start_tsc; u32_t mutex_lock_end_tsc; u32_t mutex_lock_diff = 0; u32_t mutex_unlock_start_tsc; u32_t mutex_unlock_end_tsc; u32_t mutex_unlock_diff = 0; for (int i = 0; i < 1000; i++) { mutex_lock_start_tsc = OS_GET_TIME(); k_mutex_lock(&mutex0, 100); mutex_lock_end_tsc = OS_GET_TIME(); mutex_unlock_start_tsc = OS_GET_TIME(); k_mutex_unlock(&mutex0); mutex_unlock_end_tsc = OS_GET_TIME(); mutex_lock_diff += (mutex_lock_end_tsc - mutex_lock_start_tsc); mutex_unlock_diff += (mutex_unlock_end_tsc - mutex_unlock_start_tsc); } PRINT_F("Mutex lock", mutex_lock_diff / 1000, SYS_CLOCK_HW_CYCLES_TO_NS(mutex_lock_diff / 1000)); PRINT_F("Mutex unlock", mutex_unlock_diff / 1000, SYS_CLOCK_HW_CYCLES_TO_NS(mutex_unlock_diff / 1000)); }
unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const uint8_t *spData) { unsigned char status = 0; unsigned short offset = 0; unsigned char* spDataPtr = (unsigned char*)spData; uint8_t rambuffer[SP_PORTION_SIZE]; while ((status == 0) && (spLength >= SP_PORTION_SIZE)) { Serial.println("#"); for (uint8_t i=0; i<SP_PORTION_SIZE; i++) { //#ifdef TEENSY3 //rambuffer[i] = *(spData + i + offset); //#else //rambuffer[i] = pgm_read_byte(spData + i + offset); //#endif while (Serial.available() <= 0) ; rambuffer[i] = Serial.read(); } #if (DEBUG_MODE == 1) PRINT_F("Writing: "); printDec16(offset); PRINT_F("\t"); for (uint8_t i=0; i<SP_PORTION_SIZE; i++) { PRINT_F("0x"); printHex(rambuffer[i]); PRINT_F(", "); } PRINT_F("\n\r"); #endif status = nvmem_write(ulFileId, SP_PORTION_SIZE, offset, rambuffer); //status = 0; offset += SP_PORTION_SIZE; spLength -= SP_PORTION_SIZE; spDataPtr += SP_PORTION_SIZE; } if (status !=0) { // NVMEM error occurred return status; } if (spLength != 0) { Serial.println("#"); for (int i=0; i<spLength; i++) { while (Serial.available() <= 0) ; rambuffer[i] = Serial.read(); } // if reached here, a reminder is left status = nvmem_write(ulFileId, spLength, offset, rambuffer); //status = 0; } return status; }
/** * * @brief Memory pool get/free test * * @return N/A */ void mempool_test(void) { u32_t et; /* elapsed time */ int i; s32_t return_value = 0; struct k_mem_block block; PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_POOL_RUNS; i++) { return_value |= k_mem_pool_alloc(&DEMOPOOL, &block, 16, K_FOREVER); k_mem_pool_free(&block); } et = TIME_STAMP_DELTA_GET(et); check_result(); if (return_value != 0) { k_panic(); } PRINT_F(output_file, FORMAT, "average alloc and dealloc memory pool block", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS))); }
void panoDumpImage(Image *im, char *label, int indent) { char ind[MAX_INDENT+1]; int i; if (im == NULL) return; // prepare indent panoDumpSetIndent(ind, indent); if (label != NULL) { fprintf(stderr, "%s%s\n", ind, label); } #define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)im) #define PRINT_F(a) PRINT_GENERIC(a,"%f", im) #define PRINT_S(a) PRINT_GENERIC(a,"\"%s\"", im) fprintf(stderr, "%sImage Data\n", ind); PRINT_INT(width); PRINT_INT(height); PRINT_INT(bytesPerLine); PRINT_INT(bitsPerPixel); PRINT_INT(dataSize); PRINT_INT(dataformat); PRINT_INT(format); PRINT_INT(formatParamCount); for (i=0;i< im->formatParamCount; i++) { fprintf(stderr, "%s\t\tformat Param[%d] %f\n", ind, i, im->formatParam[i]); } PRINT_F(hfov); PRINT_F(yaw); PRINT_F(roll); PRINT_F(pitch); PRINT_S(name); panoDumpCorrectPrefs(&im->cP, NULL, indent+1); panoDumpPTRect(&im->selection, NULL,indent+1); panoDumpCropInfo(&im->cropInformation, NULL, indent+1); #undef PRINT_INT #undef PRINT_F #undef PRINT_S }
int main() { FILE *input, *output; input=fopen("input.dat","r"); output=fopen("output.dat","w"); int x; char c[1024]; lista = (SENTINEL*) malloc(sizeof(SENTINEL)); lista->head=0; lista->tail=0; while(fscanf(input,"%s",c)!=EOF) { if(strcmp(c,"PRINT_ALL")==0) PRINT_ALL(output); else if(strcmp(c,"AF")==0) { fscanf(input,"%d",&x); AF(x); } else if(strcmp(c,"AL")==0) { fscanf(input,"%d",&x); AL(x); } else if(strcmp(c,"DF")==0) DF(); else if(strcmp(c,"DL")==0) DL(); else if(strcmp(c,"DOOM_THE_LIST")==0) DOOM_THE_LIST(); else if(strcmp(c,"DE")==0) { fscanf(input,"%d",&x); DE(x); } else if(strcmp(c,"PRINT_F")==0) { fscanf(input,"%d",&x); PRINT_F(x,output); } else if(strcmp(c,"PRINT_L")==0) { fscanf(input,"%d",&x); PRINT_L(x,output); } } return 0; }
int main() { FILE *g; l=0; head=NULL; tail=NULL; g=fopen("input.txt", "r"); char cuvant[15]; int n; if (g==NULL) { printf("Error in opening the file."); exit(1); } while(fscanf(g,"%s",cuvant)>0) { if (strcmp(cuvant,"AF")==0) { fscanf(g,"%d",&n); AF(n); } else if (strcmp(cuvant,"AL")==0) { fscanf(g,"%d",&n); AL(n); } else if (strcmp(cuvant,"DF")==0) DF(); else if(strcmp(cuvant,"DL")==0) DL(); else if(strcmp(cuvant,"DE")==0) { fscanf(g,"%d",&n); DE(n); } else if(strcmp(cuvant,"PRINT_ALL")==0) PRINT_ALL(); else if(strcmp(cuvant,"PRINT_F")==0) { fscanf(g,"%d",&n); PRINT_F(n); } else if(strcmp(cuvant,"PRINT_L")==0) { fscanf(g,"%d",&n); PRINT_L(n); } else if(strcmp(cuvant,"DOOM_THE_LIST")==0) DOOM_THE_LIST(); } fclose(g); printf("%d",l); return 0; }
unsigned char nvmem_write_patch(unsigned long ulFileId, unsigned long spLength, const uint8_t *spData) { unsigned char status = 0; unsigned short offset = 0; unsigned char* spDataPtr = (unsigned char*)spData; uint8_t rambuffer[SP_PORTION_SIZE]; while ((status == 0) && (spLength >= SP_PORTION_SIZE)) { for (uint8_t i=0; i<SP_PORTION_SIZE; i++) { rambuffer[i] = pgm_read_byte(spData + i + offset); } #if (DEBUG_MODE == 1) PRINT_F("Writing: "); printDec16(offset); PRINT_F("\t"); for (uint8_t i=0; i<SP_PORTION_SIZE; i++) { PRINT_F("0x"); printHex(rambuffer[i]); PRINT_F(", "); } PRINT_F("\n\r"); #endif status = nvmem_write(ulFileId, SP_PORTION_SIZE, offset, rambuffer); offset += SP_PORTION_SIZE; spLength -= SP_PORTION_SIZE; spDataPtr += SP_PORTION_SIZE; } if (status !=0) { // NVMEM error occurred return status; } if (spLength != 0) { memcpy_P(rambuffer, spDataPtr, SP_PORTION_SIZE); // if reached here, a reminder is left status = nvmem_write(ulFileId, spLength, offset, rambuffer); } return status; }
UINT8 nvmem_write_patch(UINT32 ulFileId, UINT32 spLength, const UINT8 *spData) { UINT8 status = 0; UINT16 offset = 0; UINT8* spDataPtr = (UINT8*)spData; UINT8 rambuffer[SP_PORTION_SIZE]; while ((status == 0) && (spLength >= SP_PORTION_SIZE)) { for (UINT8 i=0; i<SP_PORTION_SIZE; i++) { rambuffer[i] = pgm_read_byte(spData + i + offset); } #if (DEBUG_MODE == 1) PRINT_F("Writing: "); printDec16(offset); PRINT_F("\t"); for (UINT8 i=0; i<SP_PORTION_SIZE; i++) { PRINT_F("0x"); printHex(rambuffer[i]); PRINT_F(", "); } PRINT_F("\n\r"); #endif status = nvmem_write(ulFileId, SP_PORTION_SIZE, offset, rambuffer); offset += SP_PORTION_SIZE; spLength -= SP_PORTION_SIZE; spDataPtr += SP_PORTION_SIZE; } if (status !=0) { // NVMEM error occurred return status; } if (spLength != 0) { memcpy_P(rambuffer, spDataPtr, SP_PORTION_SIZE); // if reached here, a reminder is left status = nvmem_write(ulFileId, spLength, offset, rambuffer); } return status; }
signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength, unsigned long ulEntryOffset, unsigned char *buff) { long iRes; unsigned char *ptr; unsigned char *args; iRes = EFAIL; ptr = tSLInformation.pucTxCommandBuffer; args = (ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE); // Fill in HCI packet structure args = UINT32_TO_STREAM(args, ulFileId); args = UINT32_TO_STREAM(args, 12); args = UINT32_TO_STREAM(args, ulLength); args = UINT32_TO_STREAM(args, ulEntryOffset); memcpy((ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE + NVMEM_WRITE_PARAMS_LEN),buff,ulLength); #if (DEBUG_MODE == 1) PRINT_F("Writing:\t"); for (uint8_t i=0; i<ulLength; i++) { PRINT_F("0x"); printHex(buff[i]); PRINT_F(", "); } PRINT_F("\n\r"); #endif // Initiate a HCI command but it will come on data channel hci_data_command_send(HCI_CMND_NVMEM_WRITE, ptr, NVMEM_WRITE_PARAMS_LEN, ulLength); SimpleLinkWaitEvent(HCI_EVNT_NVMEM_WRITE, &iRes); return(iRes); }
/** * * @brief Mutex lock/unlock test * * @return N/A */ void mutex_test(void) { u32_t et; /* elapsed time */ int i; PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_MUTEX_RUNS; i++) { k_mutex_lock(&DEMO_MUTEX, K_FOREVER); k_mutex_unlock(&DEMO_MUTEX); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "average lock and unlock mutex", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS))); }
/** * * @brief Mailbox transfer speed test * * @return N/A */ void mailbox_test(void) { u32_t putsize; u32_t puttime; int putcount; unsigned int EmptyMsgPutTime; GetInfo getinfo; PRINT_STRING(dashline, output_file); PRINT_STRING("| " "M A I L B O X M E A S U R E M E N T S" " |\n", output_file); PRINT_STRING(dashline, output_file); PRINT_STRING("| Send mailbox message to waiting high " "priority task and wait |\n", output_file); PRINT_F(output_file, "| repeat for %4d times and take the " "average |\n", NR_OF_MBOX_RUNS); PRINT_STRING(dashline, output_file); PRINT_HEADER(); PRINT_STRING(dashline, output_file); k_sem_reset(&SEM0); k_sem_give(&STARTRCV); putcount = NR_OF_MBOX_RUNS; putsize = 0; mailbox_put(putsize, putcount, &puttime); /* waiting for ack */ k_msgq_get(&MB_COMM, &getinfo, K_FOREVER); PRINT_ONE_RESULT(); EmptyMsgPutTime = puttime; for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) { mailbox_put(putsize, putcount, &puttime); /* waiting for ack */ k_msgq_get(&MB_COMM, &getinfo, K_FOREVER); PRINT_ONE_RESULT(); } PRINT_STRING(dashline, output_file); PRINT_OVERHEAD(); PRINT_XFER_RATE(); }
int main() { char strng[20]; int value; FILE *d; d= fopen("input.dat", "r"); while(fscanf(d, "%s %d", &strng, &value)!=EOF) { if (strcmp(strng,"AF")==0) AddFirst(value); if (strcmp(strng,"AL")==0) AddLast(value); if (strcmp(strng,"PRINT_ALL")==0) print_list(); if (strcmp(strng,"DF")==0) DelFirst(); if (strcmp(strng,"DL")==0) DelLast(); if (strcmp(strng,"DOOM_THE_LIST")==0) DoomTheList(); if (strcmp(strng,"DE")==0) DelAnElement(value); if (strcmp(strng,"PRINT_F")==0) PRINT_F(value); if (strcmp(strng,"PRINT_L")==0) PRINT_L(value); } fclose(d); return 0; }
void panoDumpAdjustData(aPrefs* aP, char *label, int indent) { char ind[MAX_INDENT+1]; assert (aP != NULL); panoDumpSetIndent(ind, indent); if (label != NULL) { fprintf(stderr, "%s%s\n", ind, label); } fprintf(stderr, "%s\tAdjust Data\n", ind); #define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)aP) #define PRINT_F(a) PRINT_GENERIC(a,"%f", aP) #define PRINT_S(a) PRINT_GENERIC(a,"\"%s\"", aP) PRINT_INT(mode); PRINT_S(scriptFile.name); PRINT_INT(nt); PRINT_INT(interpolator); PRINT_F(gamma); PRINT_INT(fastStep); #undef PRINT_INT #undef PRINT_F #undef PRINT_S panoDumpImage(&aP->im, "Input Image", indent + 1); panoDumpImage(&aP->pano, "Panorama", indent + 1); }
/** * * @brief Semaphore signal speed test * * @return N/A */ void sema_test(void) { uint32_t et; /* elapsed Time */ int i; PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM0); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal semaphore", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); task_sem_reset(SEM1); task_sem_give(STARTRCV); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM1); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waiting high pri task", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM1); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waiting high pri task, with timeout", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM2); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (2)", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM2); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (2), with timeout", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM3); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (3)", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM3); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (3), with timeout", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM4); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (4)", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { task_sem_give(SEM4); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (4), with timeout", SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); }
void semaphore_bench(void) { /* Thread yield*/ sem0_tid = k_thread_create(&my_thread, my_stack_area, STACK_SIZE, thread_sem0_test, NULL, NULL, NULL, 2 /*priority*/, 0, 0); sem1_tid = k_thread_create(&my_thread_0, my_stack_area_0, STACK_SIZE, thread_sem1_test, NULL, NULL, NULL, 2 /*priority*/, 0, 0); k_sleep(1000); /* u64_t test_time1 = _tsc_read(); */ sem_end_time = (__common_var_swap_end_tsc); u32_t sem_cycles = sem_end_time - sem_start_time; sem0_tid = k_thread_create(&my_thread, my_stack_area, STACK_SIZE, thread_sem0_give_test, NULL, NULL, NULL, 2 /*priority*/, 0, 0); sem1_tid = k_thread_create(&my_thread_0, my_stack_area_0, STACK_SIZE, thread_sem1_give_test, NULL, NULL, NULL, 2 /*priority*/, 0, 0); k_sleep(1000); sem_give_end_time = (__common_var_swap_end_tsc); u32_t sem_give_cycles = sem_give_end_time - sem_give_start_time; /* Semaphore without context switch*/ u32_t sem_give_wo_cxt_start = OS_GET_TIME(); k_sem_give(&sem_bench); u32_t sem_give_wo_cxt_end = OS_GET_TIME(); u32_t sem_give_wo_cxt_cycles = sem_give_wo_cxt_end - sem_give_wo_cxt_start; u32_t sem_take_wo_cxt_start = OS_GET_TIME(); k_sem_take(&sem_bench, 10); u32_t sem_take_wo_cxt_end = OS_GET_TIME(); u32_t sem_take_wo_cxt_cycles = sem_take_wo_cxt_end - sem_take_wo_cxt_start; /* TC_PRINT("test_time1 , %d cycles\n", (u32_t)test_time1); */ /* TC_PRINT("test_time2 , %d cycles\n", (u32_t)test_time2); */ PRINT_F("Semaphore Take with context switch", sem_cycles, SYS_CLOCK_HW_CYCLES_TO_NS(sem_cycles)); PRINT_F("Semaphore Give with context switch", sem_give_cycles, SYS_CLOCK_HW_CYCLES_TO_NS(sem_give_cycles)); PRINT_F("Semaphore Take without context switch", sem_take_wo_cxt_cycles, SYS_CLOCK_HW_CYCLES_TO_NS(sem_take_wo_cxt_cycles)); PRINT_F("Semaphore Give without context switch", sem_give_wo_cxt_cycles, SYS_CLOCK_HW_CYCLES_TO_NS(sem_give_wo_cxt_cycles)); }
//------------------------------------------------------------------------------ /// Do file system tests /// \return test result, 1: success. //------------------------------------------------------------------------------ static void LoadImage(void) { unsigned int i, j; unsigned int ByteToRead; unsigned int ByteRead; U8 buf, cnt; FRESULT res; DIR dirs; FATFS fs; // File system object FIL FileObject; if (!MEDSdcard_Initialize(&medias[ID_DRV], MCI_ID)) { TRACE_ERR("SD Init fail\n\r"); return; } numMedias = 1; // Mount disk DEBUG_MSG("Mount disk %d", ID_DRV); memset(&fs, 0, sizeof(FATFS)); // Clear file system object res = f_mount(ID_DRV, &fs); if( res != FR_OK ) { TRACE_ERR("f_mount pb: 0x%X", res); return; } // Test if the disk is formated res = f_opendir (&dirs,STR_ROOT_DIRECTORY); if(res == FR_OK ) { scan_files(STR_ROOT_DIRECTORY); res = f_open(&FileObject, zImageName, FA_OPEN_EXISTING|FA_READ); if( res != FR_OK ) { TRACE_ERR("f_open read pb: 0x%X", res); return; } // Read file DEBUG_MSG("Read file"); ByteToRead = FileObject.fsize; res = f_read(&FileObject, (void*)0x70008000, ByteToRead, &ByteRead); if(res != FR_OK) { TRACE_ERR("f_read pb: 0x%X", res); return; } res = f_open(&FileObject, gridName, FA_OPEN_EXISTING|FA_READ); if( res != FR_OK ) { TRACE_ERR("f_open read pb: 0x%X", res); return; } ByteToRead = FileObject.fsize; res = f_read(&FileObject, (void*)0x71008000, ByteToRead, &ByteRead); if(res != FR_OK) { TRACE_ERR("f_read pb: 0x%X", res); return; } } PRINT_F("\n\r\n\r"); FPGA_CONF_N(); FPGA_CONF_P(); while(!FPGA_STAT); for(i=0;i<0x1000000;i++) { buf = SFR_RD8(0x71008000+i); for(cnt = 0; cnt < 8; cnt++) { if(((buf>>(cnt))&(0x1))==0x1) { FPGA_DATA_P(); } else { FPGA_DATA_N(); } FPGA_DCLK_P(); FPGA_DCLK_N(); } if(FPGA_DONE) break; }
void panoDumpCorrectPrefs(cPrefs *cP, char *label, int indent) { char ind[MAX_INDENT+1]; int i,j; panoDumpSetIndent(ind, indent); #define PRINT_INT(a) PRINT_GENERIC(a,"%d", (int)cP) #define PRINT_F(a) PRINT_GENERIC(a,"%f", cP) if (label != NULL) { fprintf(stderr, "%s%s\n", ind, label); } fprintf(stderr, "%sCorrect Preferences\n", ind); if (cP->radial) { for (i=0;i<3;i++) { for (j=0;j<5;j++) { fprintf(stderr, "%s\tradial_params[%d][%d]\t%f\n", ind, i, j, cP->radial_params[i][j]); } } } if (cP->vertical) { for (i=0;i<3;i++) { fprintf(stderr, "%s\tvertical_params[%d]\t%f\n", ind, i, cP->vertical_params[i]); } } if (cP->horizontal) { for (i=0;i<3;i++) { fprintf(stderr, "%s\thorizontal_params[%d]\t%f\n", ind, i, cP->horizontal_params[i]); } } if (cP->shear) { PRINT_F(shear_x); PRINT_F(shear_y); } if (cP->tilt) { PRINT_F(tilt_x); PRINT_F(tilt_y); PRINT_F(tilt_z); PRINT_F(tilt_scale); } if (cP->trans) { PRINT_F(trans_x); PRINT_F(trans_y); PRINT_F(trans_z); PRINT_F(trans_yaw); PRINT_F(trans_pitch); } if (cP->test) { PRINT_F(test_p0); PRINT_F(test_p1); PRINT_F(test_p2); PRINT_F(test_p3); } /* I don't think these files are read as parameters... we'll see int resize; int32_t width; int32_t height; int luminance; double lum_params[3]; int correction_mode; int cutFrame; int fwidth; int fheight; int frame; int fourier; int fourier_mode; fullPath psf; int fourier_nf; fullPath nff; double filterfactor; double fourier_frame; */ #undef PRINT_INT #undef PRINT_F }
int main(int argc, char* argv[]) { char* inputFileName = "I:/Programs/VegaFEM-v2.1/models/turtle/turtle-volumetric-homogeneous.veg"; VolumetricMesh* volumetricMesh = VolumetricMeshLoader::load(inputFileName); if (volumetricMesh == NULL) { PRINT_F("load failed!"); } else { PRINT_F("%d vertices, %d elements", volumetricMesh->getNumVertices(), volumetricMesh->getNumElements()); } TetMesh* tetMesh; if (volumetricMesh->getElementType() == VolumetricMesh::TET) { tetMesh = (TetMesh*) volumetricMesh; } else PRINT_F("not a tet mesh\n"); CorotationalLinearFEM* deformableModel = new CorotationalLinearFEM(tetMesh); ForceModel* forceModel = new CorotationalLinearFEMForceModel(deformableModel); int nVtx = tetMesh->getNumVertices(); int r = 3 * nVtx; double timestep = 0.0333; SparseMatrix* massMatrix; GenerateMassMatrix::computeMassMatrix(tetMesh, &massMatrix, true); massMatrix->SaveToMatlabFormat("massMatrix.m"); PRINT_F("%d rows, %d cols\n", massMatrix->GetNumRows(), massMatrix->GetNumColumns()); int positiveDefiniteSolver = 0; int numConstrainedDOFs = 9; int constrainedDOFs[9]= {12,13,14,30,31,32,42,43,44}; double dampingMassCoef = 0.0; double dampingStiffnessCoef = 0.01; ImplicitBackwardEulerSparse* integrator = new ImplicitBackwardEulerSparse(r, timestep, massMatrix, forceModel, positiveDefiniteSolver, numConstrainedDOFs, constrainedDOFs, dampingMassCoef, dampingStiffnessCoef); //CentralDifferencesSparse* integrator = new CentralDifferencesSparse(r, timestep, massMatrix, forceModel, numConstrainedDOFs, constrainedDOFs, dampingMassCoef, dampingStiffnessCoef); double * f = new double[r]; int numTimesteps = 10; double*u = new double[r]; for (int i = 0; i < numTimesteps; ++i) { integrator->SetExternalForcesToZero(); if (i==0) { for (int j = 0; j < r; j++) f[j] = 0; f[37] = -500; integrator->SetExternalForces(f); } integrator->GetqState(u); PRINT_F("v = [", i); for (int ithVtx = 0; ithVtx < nVtx; ++ithVtx) PRINT_F("%lf, %lf, %lf\n", u[ithVtx*3],u[ithVtx*3+1],u[ithVtx*3+2]); PRINT_F("];"); integrator->DoTimestep(); } return 0; }