void NSNeutronEqResid<EvalT, Traits>:: evaluateFields(typename Traits::EvalData workset) { typedef Intrepid::FunctionSpaceTools FST; FST::scalarMultiplyDataData<ScalarT> (flux, NeutronDiff, NGrad); FST::integrate<ScalarT>(NResidual, flux, wGradBF, Intrepid::COMP_CPP, false); // "false" overwrites for (std::size_t cell=0; cell < workset.numCells; ++cell) { for (std::size_t qp=0; qp < numQPs; ++qp) { abscoeff(cell,qp) = (Absorp(cell,qp) - nu(cell,qp)*Fission(cell,qp)) * Neutron(cell,qp); if (haveNeutSource) abscoeff(cell,qp) -= Source(cell,qp); } } FST::integrate<ScalarT>(NResidual, abscoeff, wBF, Intrepid::COMP_CPP, true); // "true" sums into }
int scene::loadMaterial(string materialid){ int id = atoi(materialid.c_str()); if(id!=materials.size()){ cout << "ERROR: MATERIAL ID does not match expected number of materials" << endl; return -1; }else{ cout << "Loading Material " << id << "..." << endl; material newMaterial; //load static properties for(int i=0; i<12; i++){ string line; utilityCore::safeGetline(fp_in,line); vector<string> tokens = utilityCore::tokenizeString(line); if(strcmp(tokens[0].c_str(), "RGB")==0){ glm::vec3 color( atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str()) ); newMaterial.color = color; }else if(strcmp(tokens[0].c_str(), "SPECEX")==0){ newMaterial.specularExponent = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "SPECRGB")==0){ glm::vec3 specColor( atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str()) ); newMaterial.specularColor = specColor; }else if(strcmp(tokens[0].c_str(), "REFL")==0){ newMaterial.hasReflective = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "REFR")==0){ newMaterial.hasRefractive = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "REFRIOR")==0){ newMaterial.indexOfRefraction = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "SCATTER")==0){ newMaterial.hasScatter = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "ABSCOEFF")==0){ glm::vec3 abscoeff( atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str()) ); newMaterial.absorptionCoefficient = abscoeff; }else if(strcmp(tokens[0].c_str(), "RSCTCOEFF")==0){ newMaterial.reducedScatterCoefficient = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "EMITTANCE")==0){ newMaterial.emittance = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "DIFFCOEFF")==0){ newMaterial.diffuseCoefficient = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "SPECCOEFF")==0){ newMaterial.specularCoefficient = atof(tokens[1].c_str()); } } materials.push_back(newMaterial); return 1; } }
int scene::loadMaterial(string materialid){ int id = atoi(materialid.c_str()); if(id!=materials.size()){ cout << "ERROR: MATERIAL ID does not match expected number of materials" << endl; return -1; }else{ cout << "Loading Material " << id << "..." << endl; material newMaterial; newMaterial.hasTexture = false; newMaterial.Texture.texelHeight = 0; newMaterial.Texture.texelWidth = 0; newMaterial.hasNormalMap = false; newMaterial.NormalMap.texelHeight = 0; newMaterial.NormalMap.texelWidth = 0; //load static properties for(int i=0; i<10; i++){ string line; utilityCore::safeGetline(fp_in,line); vector<string> tokens = utilityCore::tokenizeString(line); if(strcmp(tokens[0].c_str(), "RGB")==0){ glm::vec3 color( atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str()) ); newMaterial.color = color; }else if(strcmp(tokens[0].c_str(), "SPECEX")==0){ newMaterial.specularExponent = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "SPECRGB")==0){ glm::vec3 specColor( atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str()) ); newMaterial.specularColor = specColor; }else if(strcmp(tokens[0].c_str(), "REFL")==0){ newMaterial.hasReflective = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "REFR")==0){ newMaterial.hasRefractive = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "REFRIOR")==0){ newMaterial.indexOfRefraction = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "SCATTER")==0){ newMaterial.hasScatter = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "ABSCOEFF")==0){ glm::vec3 abscoeff( atof(tokens[1].c_str()), atof(tokens[2].c_str()), atof(tokens[3].c_str()) ); newMaterial.absorptionCoefficient = abscoeff; }else if(strcmp(tokens[0].c_str(), "RSCTCOEFF")==0){ newMaterial.reducedScatterCoefficient = atof(tokens[1].c_str()); }else if(strcmp(tokens[0].c_str(), "EMITTANCE")==0){ newMaterial.emittance = atof(tokens[1].c_str()); } else if (strcmp(tokens[0].c_str(), "TEXTURE")==0) { int nComps; unsigned char *bytes = stbi_load(tokens [1].c_str (), &newMaterial.Texture.texelWidth, &newMaterial.Texture.texelHeight, &nComps, 3); if (bytes) { newMaterial.hasTexture = true; newMaterial.Texture.texels = new glm::vec3 [newMaterial.Texture.texelWidth * newMaterial.Texture.texelHeight]; for (int i = 0; i < (newMaterial.Texture.texelWidth * newMaterial.Texture.texelHeight); i ++) { newMaterial.Texture.texels [i].r = bytes [3*i] / 255.0; newMaterial.Texture.texels [i].g = bytes [3*i + 1] / 255.0; newMaterial.Texture.texels [i].b = bytes [3*i + 2] / 255.0; } } } else if (strcmp(tokens[0].c_str(), "NMAP")==0) { int nComps; unsigned char *bytes = stbi_load(tokens [1].c_str (), &newMaterial.NormalMap.texelWidth, &newMaterial.NormalMap.texelHeight, &nComps, 3); if (bytes) { newMaterial.hasNormalMap = true; newMaterial.NormalMap.texels = new glm::vec3 [newMaterial.NormalMap.texelWidth * newMaterial.NormalMap.texelHeight]; for (int i = 0; i < (newMaterial.Texture.texelWidth * newMaterial.NormalMap.texelHeight); i ++) { newMaterial.NormalMap.texels [i].r = bytes [3*i] / 255.0; newMaterial.NormalMap.texels [i].g = bytes [3*i + 1] / 255.0; newMaterial.NormalMap.texels [i].b = bytes [3*i + 2] / 255.0; } } } } materials.push_back(newMaterial); return 1; } }