1//this function uses parsePrefix.js to record the JSON data in sub into the object 'data' 2 3function recordSawsData(data, sub) { 4 5 if (sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables._title.data == "Preconditioner (PC) options") { 6 var SAWs_pcVal = sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables["-pc_type"].data[0]; 7 var SAWs_alternatives = sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables["-pc_type"].alternatives; 8 var SAWs_prefix = sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables["prefix"].data[0]; 9 10 if (SAWs_prefix == "(null)") 11 SAWs_prefix = ""; 12 13 //this func returns an object with two pieces of information: the endtag and the new word encountered (if any) 14 var parsedInfo = parsePrefix(data, SAWs_prefix); 15 var endtag = parsedInfo.endtag; 16 var newWord = parsedInfo.newWord; 17 18 if(data[endtag] == undefined) 19 data[endtag] = new Object(); 20 21 data[endtag].pc_type = SAWs_pcVal; 22 data[endtag].pc_type_alternatives = SAWs_alternatives.slice(); //deep copy of alternatives 23 24 if (SAWs_pcVal == 'bjacobi') {//some extra data for pc=bjacobi 25 data[endtag].pc_bjacobi_blocks = sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables["-pc_bjacobi_blocks"].data[0]; 26 } 27 28 if(SAWs_pcVal == 'mg') {//some extra data for pc=multigrid 29 data[endtag].pc_mg_levels = 1;//make it 1 level by default. when another mg_level is encountered, this variable will be overwritten 30 } 31 32 if(SAWs_pcVal == 'fieldsplit') { //some extra data for pc=fieldsplit 33 data[endtag].pc_fieldsplit_blocks = 1;//make it 1 block by default. when another fieldsplit is encountered, this variable will be overwritten 34 } 35 36 //check if parent was mg because then this child is a mg_level and we might need to record a new record for mg_level. we need to do this because the variable mg_levels is still not available in saws yet. 37 var parentEndtag = getParent(endtag); 38 39 if(data[parentEndtag] != undefined && data[parentEndtag].pc_type == "mg") { //check to see if parent was mg 40 var currentLevel = endtag.substring(endtag.lastIndexOf('_')+1, endtag.length);//everything after the last underscore 41 currentLevel = parseInt(currentLevel); 42 data[parentEndtag].pc_mg_levels = currentLevel+1;//if we are on level 0 then that means there was 1 level so far 43 } 44 45 if(data[parentEndtag] != undefined && data[parentEndtag].pc_type == "fieldsplit"){ //check to see if parent was fieldsplit 46 var currentLevel = endtag.substring(endtag.lastIndexOf('_')+1, endtag.length);//everything after the last underscore 47 currentLevel = parseInt(currentLevel); 48 data[parentEndtag].pc_fieldsplit_blocks = currentLevel + 1; 49 if(newWord != "") 50 data[endtag].name = newWord;//important! record name of the fieldsplit 51 } 52 } 53 54 /* ---------------------------------- KSP OPTIONS --------------------------------- */ 55 56 else if (sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables._title.data == "Krylov Method (KSP) options") { 57 var SAWs_kspVal = sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables["-ksp_type"].data[0]; 58 var SAWs_alternatives = sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables["-ksp_type"].alternatives; 59 var SAWs_prefix = sub.directories.SAWs_ROOT_DIRECTORY.directories.PETSc.directories.Options.variables.prefix.data[0]; 60 61 if (SAWs_prefix == "(null)") 62 SAWs_prefix = ""; 63 64 //this func returns an object with two pieces of information: the endtag and the new word encountered (if any) 65 var parsedInfo = parsePrefix(data, SAWs_prefix); 66 var endtag = parsedInfo.endtag; 67 var newWord = parsedInfo.newWord; 68 69 data[endtag].ksp_type = SAWs_kspVal; 70 data[endtag].ksp_type_alternatives = SAWs_alternatives.slice();//deep copy of alternatives 71 } 72} 73