def generateCode(self): self.m_context["solverNamespace"] = self.m_context["solverName"].split( "::")[0] self.m_context["solverClass"] = self.m_context["solverName"].split( "::")[1] TemplatingUtils.renderAsFile("Kernels_h.template", self.m_filename, self.m_context)
def generateCode(self): gemmName = "gemm_" + str(self.m_context["nVar"]) + "_" + str( self.m_context["nDof"]) + "_" + str(self.m_context["nDof"]) self.m_context["gemm_gradQ_x"] = gemmName + "_gradQ_x" self.m_context["gemm_gradQ_y"] = gemmName + "_gradQ_y" self.m_context["gemm_gradQ_z"] = gemmName + "_gradQ_z" if (self.m_context["isLinear"]): self.m_context["ncpOutputShift"] = Backend.getSizeWithPadding( self.m_context["nVar"] * self.m_context["nDim"] ) #shift used to split the tmpArray into input and output for NCP # size of the tmpArray self.m_context["tmpArraySize"] = max((self.m_context["nDof"]*self.m_context["nVarPad"] if self.m_context["useFlux"] else 0), \ (self.m_context["nVar"]*self.m_context["nDim"] if self.m_context["useMaterialParam"] else 0), \ (2*self.m_context["ncpOutputShift"] if self.m_context["useNCP"] else 0)) self.m_context["gemm_flux_x"] = gemmName + "_flux_x" self.m_context["gemm_flux_y"] = gemmName + "_flux_y" self.m_context["gemm_flux_z"] = gemmName + "_flux_z" TemplatingUtils.renderAsFile( "spaceTimePredictorLinear_cpp.template", self.m_filename_linear, self.m_context) else: self.m_context["nDof_seq"] = range(0, self.m_context["nDof"]) self.m_context["gemm_rhs_x"] = gemmName + "_rhs_x" self.m_context["gemm_rhs_y"] = gemmName + "_rhs_y" self.m_context["gemm_rhs_z"] = gemmName + "_rhs_z" self.m_context["gemm_lqi"] = gemmName + "_lqi" TemplatingUtils.renderAsFile( "spaceTimePredictorNonLinear_cpp.template", self.m_filename_nonlinear, self.m_context) # generates gemms if (self.m_context["useLibxsmm"]): self.generateGemms()
def generateCode(self): if (self.m_context["isLinear"]): # render template TemplatingUtils.renderAsFile("riemannSolverLinear_cpp.template", self.m_filename, self.m_context) else: # render template TemplatingUtils.renderAsFile("riemannSolverNonLinear_cpp.template", self.m_filename, self.m_context)
def generateCode(self): self.m_context["gemm_prefix"] = "gemm" TemplatingUtils.renderAsFile("gemmsCPP_h.template", self.m_filenameRoot + ".h", self.m_context) TemplatingUtils.renderAsFile("gemmsCPP_cpp.template", self.m_filenameRoot + ".cpp", self.m_context)
def generateCode(self): self.m_context["noVarPadding"] = self.m_context[ "nVarPad"] == self.m_context["nVar"] TemplatingUtils.renderAsFile("converter_h.template", self.m_filenameRoot + ".h", self.m_context) TemplatingUtils.renderAsFile("converter_cpp.template", self.m_filenameRoot + ".cpp", self.m_context)
def generateCode(self): self.m_context["gemm_face_Q"] = "gemm_" + str( self.m_context["nData"]) + "_" + str( self.m_context["nDof"]) + "_" + str( self.m_context["nDof"]) + "_face_Q" self.m_context["gemm_face_F"] = "gemm_" + str( self.m_context["nVar"]) + "_" + str( self.m_context["nDof"]) + "_" + str( self.m_context["nDof"]) + "_face_F" self.m_context["gemm_volume"] = "gemm_" + str( self.m_context["nData"]) + "_" + str( self.m_context["nDof"]) + "_" + str( self.m_context["nDof"]) + "_volume" TemplatingUtils.renderAsFile("amrRoutines_cpp.template", self.m_filename, self.m_context) # generates gemms if (self.m_context["useLibxsmm"]): self.generateGemms()
def generateCode(self): if(self.m_context["isLinear"]): TemplatingUtils.renderAsFile("volumeIntegralLinear_cpp.template", self.m_filename, self.m_context) else: # initialize context gemmName = "gemm_"+str(self.m_context["nVar"])+"_"+str(self.m_context["nDof"])+"_"+str(self.m_context["nDof"]) self.m_context["gemm_x"] = gemmName+"_lduh_x" self.m_context["gemm_y"] = gemmName+"_lduh_y" self.m_context["gemm_z"] = gemmName+"_lduh_z" self.m_context["i_seq"] = range(0,self.m_context["nDof"]) self.m_context["j_seq"] = range(0,self.m_context["nDof"]) if (self.m_context["nDim"] >= 3) else [0] # render template if(self.m_context["noTimeAveraging"]): TemplatingUtils.renderAsFile("volumeIntegralNonLinear_noTimeAveraging_cpp.template", self.m_filename, self.m_context) else: TemplatingUtils.renderAsFile("volumeIntegralNonLinear_cpp.template", self.m_filename, self.m_context) # generates gemms if(self.m_context["useLibxsmm"] and self.m_context["useFlux"]): #no gemm if no flux self.generateNonlinearGemms()
def generateCode(self): if(self.m_context['usePointSources']): TemplatingUtils.renderAsFile("deltaDistribution_cpp.template", self.m_filename, self.m_context)
def generateCode(self): l_padSize = self.m_context["nDofPad"] - self.m_context["nDof"] self.m_context["nDofPad_seq"] = range(self.m_context["nDofPad"]) self.m_context["nDofPadTimesnDof_seq"] = range( self.m_context["nDofPad"] * self.m_context["nDof"]) start = time.perf_counter() # [FLCoeff 0...0]; [FRCoeff 0...0]; # right now FLCoeff, FRCoeff no pad (gives no benefit w.r.t libxsmm) FLCoeff, _ = MathsUtils.BaseFunc1d(0.0, self.m_xGPN, self.m_context["nDof"]) #is also F0 FRCoeff, _ = MathsUtils.BaseFunc1d(1.0, self.m_xGPN, self.m_context["nDof"]) self.m_context["FLCoeff"] = MathsUtils.vectorPad(FLCoeff, l_padSize) self.m_context["FRCoeff"] = MathsUtils.vectorPad(FRCoeff, l_padSize) if self.m_context["runtimeDebug"]: print("FRLCoeff: " + str(time.perf_counter() - start)) # Matrices are stored in column major order (so the padding should be on the bottom rows) # [ Mat ] # [0...0] # [0...0] start = time.perf_counter() # Kxi Kxi = MathsUtils.assembleStiffnessMatrix(self.m_xGPN, self.m_wGPN, self.m_context["nDof"]) self.m_context["Kxi"] = MathsUtils.matrixPadAndFlatten_ColMajor( Kxi, l_padSize) self.m_context["Kxi_T"] = MathsUtils.matrixPadAndFlatten_RowMajor( Kxi, l_padSize) #transpose if self.m_context["runtimeDebug"]: print("Kxi: " + str(time.perf_counter() - start)) start = time.perf_counter() # iK1_T iK1 = MathsUtils.matrixInverse( MathsUtils.assembleK1(Kxi, self.m_xGPN, self.m_context["nDof"])) self.m_context["iK1_T"] = MathsUtils.matrixPadAndFlatten_RowMajor( iK1, l_padSize) #transpose if self.m_context["runtimeDebug"]: print("iK1_T: " + str(time.perf_counter() - start)) start = time.perf_counter() # dudx MM = MathsUtils.assembleMassMatrix(self.m_xGPN, self.m_wGPN, self.m_context["nDof"]) dudx = MathsUtils.assembleDiscreteDerivativeOperator(MM, Kxi) self.m_context["dudx"] = MathsUtils.matrixPadAndFlatten_ColMajor( dudx, l_padSize) self.m_context["dudx_T"] = MathsUtils.matrixPadAndFlatten_RowMajor( dudx, l_padSize) #transpose if self.m_context["runtimeDebug"]: print("dudx: " + str(time.perf_counter() - start)) start = time.perf_counter() #fineGridProjector1d fineGridProjector1d_0 = MathsUtils.assembleFineGridProjector1d( self.m_xGPN, 0, self.m_context["nDof"]) fineGridProjector1d_1 = MathsUtils.assembleFineGridProjector1d( self.m_xGPN, 1, self.m_context["nDof"]) fineGridProjector1d_2 = MathsUtils.assembleFineGridProjector1d( self.m_xGPN, 2, self.m_context["nDof"]) self.m_context[ "fineGridProjector1d_0"] = MathsUtils.matrixPadAndFlatten_ColMajor( fineGridProjector1d_0, l_padSize) self.m_context[ "fineGridProjector1d_1"] = MathsUtils.matrixPadAndFlatten_ColMajor( fineGridProjector1d_1, l_padSize) self.m_context[ "fineGridProjector1d_2"] = MathsUtils.matrixPadAndFlatten_ColMajor( fineGridProjector1d_2, l_padSize) #fineGridProjector1d_T_weighted for i in range(self.m_context["nDof"]): for j in range(self.m_context["nDof"]): fineGridProjector1d_0[i][ j] *= self.m_wGPN[i] / self.m_wGPN[j] / 3.0 fineGridProjector1d_1[i][ j] *= self.m_wGPN[i] / self.m_wGPN[j] / 3.0 fineGridProjector1d_2[i][ j] *= self.m_wGPN[i] / self.m_wGPN[j] / 3.0 self.m_context[ "fineGridProjector1d_T_weighted_0"] = MathsUtils.matrixPadAndFlatten_RowMajor( fineGridProjector1d_0, l_padSize) self.m_context[ "fineGridProjector1d_T_weighted_1"] = MathsUtils.matrixPadAndFlatten_RowMajor( fineGridProjector1d_1, l_padSize) self.m_context[ "fineGridProjector1d_T_weighted_2"] = MathsUtils.matrixPadAndFlatten_RowMajor( fineGridProjector1d_2, l_padSize) if self.m_context["runtimeDebug"]: print("fineGrid: " + str(time.perf_counter() - start)) #generate files TemplatingUtils.renderAsFile("DGMatrices_h.template", self.m_filenameRoot + ".h", self.m_context) TemplatingUtils.renderAsFile("DGMatrices_cpp.template", self.m_filenameRoot + ".cpp", self.m_context)
def generateCode(self): TemplatingUtils.renderAsFile("solutionUpdate_cpp.template", self.m_filename, self.m_context)
def generateCode(self): self.m_context["quadratureType"] = "Gauss-Legendre" l_weightsVector = MathsUtils.vectorPad( self.m_wGPN, self.m_context["nDofPad"] - self.m_context["nDof"]) self.m_context["weights1"] = l_weightsVector self.m_context["w1Size"] = len(self.m_context["weights1"]) self.m_context["w1_seq"] = range(self.m_context["w1Size"]) if (self.m_context["nDim"] == 2): # weightsVector is wGPN itself l_weightsVector = MathsUtils.vectorPad( self.m_wGPN, Backend.getPadWidth(len(self.m_wGPN))) self.m_context["weights2"] = l_weightsVector self.m_context["w2Size"] = len(self.m_context["weights2"]) self.m_context["w2_seq"] = range(self.m_context["w2Size"]) # all combinations of two weights, written as an 1D array l_weightsVector = [ self.m_wGPN[i] * self.m_wGPN[j] for i in range(self.m_context["nDof"]) for j in range(self.m_context["nDof"]) ] l_weightsVector = MathsUtils.vectorPad( l_weightsVector, Backend.getPadWidth(len(l_weightsVector))) self.m_context["weights3"] = l_weightsVector self.m_context["w3Size"] = len(self.m_context["weights3"]) self.m_context["w3_seq"] = range(self.m_context["w3Size"]) elif (self.m_context["nDim"] == 3): # all combinations of two weights, written as an 1D array l_weightsVector = [ self.m_wGPN[i] * self.m_wGPN[j] for i in range(self.m_context["nDof"]) for j in range(self.m_context["nDof"]) ] l_weightsVector = MathsUtils.vectorPad( l_weightsVector, Backend.getPadWidth(len(l_weightsVector))) self.m_context["weights2"] = l_weightsVector self.m_context["w2Size"] = len(self.m_context["weights2"]) self.m_context["w2_seq"] = range(self.m_context["w2Size"]) # all combination of three weights, written as an 1D array l_weightsVector = [ self.m_wGPN[i] * self.m_wGPN[j] * self.m_wGPN[k] for i in range(self.m_context["nDof"]) for j in range(self.m_context["nDof"]) for k in range(self.m_context["nDof"]) ] l_weightsVector = MathsUtils.vectorPad( l_weightsVector, Backend.getPadWidth(len(l_weightsVector))) self.m_context["weights3"] = l_weightsVector self.m_context["w3Size"] = len(self.m_context["weights3"]) self.m_context["w3_seq"] = range(self.m_context["w3Size"]) else: print( "WeightsGenerator.__generateWeightsCombinations(): nDim not supported" ) self.m_context["wGPN"], self.m_context[ "xGPN"] = MathsUtils.getGaussLegendre(self.m_context["nDof"]) self.m_context["GPN_seq"] = range(self.m_context["nDof"]) #generate files TemplatingUtils.renderAsFile("Quadrature_h.template", self.m_filenameRoot + ".h", self.m_context) TemplatingUtils.renderAsFile("Quadrature_cpp.template", self.m_filenameRoot + ".cpp", self.m_context)
def generateCode(self): self.m_context["isLinearCText"] = "true" if self.m_context[ "isLinear"] else "false" #c++ true/false instead of True/False TemplatingUtils.renderAsFile("configurationParameters_cpph.template", self.m_filename, self.m_context)
def generateCode(self): TemplatingUtils.renderAsFile("stableTimeStepSize_cpp.template", self.m_filename, self.m_context)
def generateCode(self): self.m_context["bndFaceSize"] = self.m_context["nVarPad"] * self.m_context["nDof"] * self.m_context["nDof3D"] TemplatingUtils.renderAsFile("surfaceIntegral_cpp.template", self.m_filename, self.m_context)
def generateCode(self): TemplatingUtils.renderAsFile("boundaryConditions_cpp.template", self.m_filename, self.m_context)