/** * update the start and end text for this ownedhierarchicalcodeblock. */ void XMLElementCodeBlock::updateContent ( ) { QString endLine = getNewLineEndingChars(); QString nodeName = getNodeName(); // Now update START/ENDING Text QString startText = '<' + nodeName; QString endText = ""; UMLAttributeList * alist = getAttributeList(); for (UMLAttribute *at = alist->first(); at; at=alist->next()) { if(at->getInitialValue().isEmpty()) kWarning()<<" XMLElementCodeBlock : cant print out attribute that lacks an initial value"<<endl; else { startText.append(" " +at->getName()+"=\""); startText.append(at->getInitialValue()+"\""); } } // now set close of starting/ending node, the style depending on whether we have child text or not if(getTextBlockList()->count()) { startText.append(">"); endText = "</" + nodeName + '>'; } else { startText.append("/>"); endText = ""; } setStartText(startText); setEndText(endText); }
int SimulationObject::initializeLbmSimulation(ntlRenderGlobals *glob) { if(! isSimworldOk() ) return 1; // already inited? if(mpLbm) return 0; mpGlob = glob; if(!getVisible()) { mpAttrs->setAllUsed(); return 0; } mGeoInitId = mpAttrs->readInt("geoinitid", mGeoInitId,"LbmSolverInterface", "mGeoInitId", false); //mDimension, mSolverType are deprecated string mSolverType(""); mSolverType = mpAttrs->readString("solver", mSolverType, "SimulationObject","mSolverType", false ); mpLbm = createSolver(); /* check lbm pointer */ if(mpLbm == NULL) { errFatal("SimulationObject::initializeLbmSimulation","Unable to init LBM solver! ", SIMWORLD_INITERROR); return 2; } debMsgStd("SimulationObject::initialized",DM_MSG,"IdStr:"<<mpLbm->getIdString() <<" LBM solver! ", 2); mpParts = new ParticleTracer(); // for non-param simulations mpLbm->setParametrizer( mpParam ); mpParam->setAttrList( getAttributeList() ); // not needed.. done in solver_init: mpParam->setSize ... in solver_interface mpParam->parseAttrList(); mpLbm->setAttrList( getAttributeList() ); mpLbm->setSwsAttrList( getSwsAttributeList() ); mpLbm->parseAttrList(); mpParts->parseAttrList( getAttributeList() ); if(! isSimworldOk() ) return 3; mpParts->setName( getName() + "_part" ); mpParts->initialize( glob ); if(! isSimworldOk() ) return 4; // init material settings string matMc("default"); matMc = mpAttrs->readString("material_surf", matMc, "SimulationObject","matMc", false ); mShowSurface = mpAttrs->readInt("showsurface", mShowSurface, "SimulationObject","mShowSurface", false ); mShowParticles = mpAttrs->readInt("showparticles", mShowParticles, "SimulationObject","mShowParticles", false ); checkBoundingBox( mGeoStart, mGeoEnd, "SimulationObject::initializeSimulation" ); mpLbm->setLbmInitId( mGeoInitId ); mpLbm->setGeoStart( mGeoStart ); mpLbm->setGeoEnd( mGeoEnd ); mpLbm->setRenderGlobals( mpGlob ); mpLbm->setName( getName() + "_lbm" ); mpLbm->setParticleTracer( mpParts ); if(mpElbeemSettings) { // set further settings from API struct init if(mpElbeemSettings->outputPath) this->mOutFilename = string(mpElbeemSettings->outputPath); mpLbm->initDomainTrafo( mpElbeemSettings->surfaceTrafo ); mpLbm->setSmoothing(1.0 * mpElbeemSettings->surfaceSmoothing, 1.0 * mpElbeemSettings->surfaceSmoothing); mpLbm->setIsoSubdivs(mpElbeemSettings->surfaceSubdivs); mpLbm->setSizeX(mpElbeemSettings->resolutionxyz); mpLbm->setSizeY(mpElbeemSettings->resolutionxyz); mpLbm->setSizeZ(mpElbeemSettings->resolutionxyz); mpLbm->setPreviewSize(mpElbeemSettings->previewresxyz); mpLbm->setRefinementDesired(mpElbeemSettings->maxRefine); mpLbm->setGenerateParticles(mpElbeemSettings->generateParticles); // set initial particles mpParts->setNumInitialParticles(mpElbeemSettings->numTracerParticles); // surface generation flag mpLbm->setSurfGenSettings(mpElbeemSettings->mFsSurfGenSetting); string dinitType = string("no"); if (mpElbeemSettings->domainobsType==FLUIDSIM_OBSTACLE_PARTSLIP) dinitType = string("part"); else if(mpElbeemSettings->domainobsType==FLUIDSIM_OBSTACLE_FREESLIP) dinitType = string("free"); else /*if(mpElbeemSettings->domainobsType==FLUIDSIM_OBSTACLE_NOSLIP)*/ dinitType = string("no"); mpLbm->setDomainBound(dinitType); mpLbm->setDomainPartSlip(mpElbeemSettings->domainobsPartslip); mpLbm->setDumpVelocities(mpElbeemSettings->generateVertexVectors); mpLbm->setFarFieldSize(mpElbeemSettings->farFieldSize); debMsgStd("SimulationObject::initialize",DM_MSG,"Added domain bound: "<<dinitType<<" ps="<<mpElbeemSettings->domainobsPartslip<<" vv"<<mpElbeemSettings->generateVertexVectors<<","<<mpLbm->getDumpVelocities(), 9 ); debMsgStd("SimulationObject::initialize",DM_MSG,"Set ElbeemSettings values "<<mpLbm->getGenerateParticles(),10); } if(! mpLbm->initializeSolverMemory() ) { errMsg("SimulationObject::initialize","initializeSolverMemory failed"); mPanic=true; return 10; } if(checkCallerStatus(FLUIDSIM_CBSTATUS_STEP, 0)) { errMsg("SimulationObject::initialize","initializeSolverMemory status"); mPanic=true; return 11; } if(! mpLbm->initializeSolverGrids() ) { errMsg("SimulationObject::initialize","initializeSolverGrids failed"); mPanic=true; return 12; } if(checkCallerStatus(FLUIDSIM_CBSTATUS_STEP, 0)) { errMsg("SimulationObject::initialize","initializeSolverGrids status"); mPanic=true; return 13; } if(! mpLbm->initializeSolverPostinit() ) { errMsg("SimulationObject::initialize","initializeSolverPostin failed"); mPanic=true; return 14; } if(checkCallerStatus(FLUIDSIM_CBSTATUS_STEP, 0)) { errMsg("SimulationObject::initialize","initializeSolverPostin status"); mPanic=true; return 15; } // print cell type stats bool printStats = true; if(glob_mpnum>0) printStats=false; // skip in this case if(printStats) { const int jmax = sizeof(CellFlagType)*8; int totalCells = 0; int flagCount[jmax]; for(int j=0; j<jmax ; j++) flagCount[j] = 0; int diffInits = 0; LbmSolverInterface::CellIdentifier cid = mpLbm->getFirstCell(); for(; mpLbm->noEndCell( cid ); mpLbm->advanceCell( cid ) ) { int flag = mpLbm->getCellFlag(cid,0); int flag2 = mpLbm->getCellFlag(cid,1); if(flag != flag2) { diffInits++; } for(int j=0; j<jmax ; j++) { if( flag&(1<<j) ) flagCount[j]++; } totalCells++; } mpLbm->deleteCellIterator( &cid ); char charNl = '\n'; debugOutNnl("SimulationObject::initializeLbmSimulation celltype stats: " <<charNl, 5); debugOutNnl("no. of cells = "<<totalCells<<", "<<charNl ,5); for(int j=0; j<jmax ; j++) { std::ostringstream out; if(flagCount[j]>0) { out<<"\t" << flagCount[j] <<" x "<< convertCellFlagType2String( (CellFlagType)(1<<j) ) <<", " << charNl; debugOutNnl(out.str(), 5); } } // compute dist. of empty/bnd - fluid - if // cfEmpty = (1<<0), cfBnd = (1<< 2), cfFluid = (1<<10), cfInter = (1<<11), if(1){ std::ostringstream out; out.precision(2); out.width(4); int totNum = flagCount[1]+flagCount[2]+flagCount[7]+flagCount[8]; double ebFrac = (double)(flagCount[1]+flagCount[2]) / totNum; double flFrac = (double)(flagCount[7]) / totNum; double ifFrac = (double)(flagCount[8]) / totNum; //??? out<<"\tFractions: [empty/bnd - fluid - interface - ext. if] = [" << ebFrac<<" - " << flFrac<<" - " << ifFrac<<"] "<< charNl; if(diffInits > 0) { debMsgStd("SimulationObject::initializeLbmSimulation",DM_MSG,"celltype Warning: Diffinits="<<diffInits<<"!" , 5); } debugOutNnl(out.str(), 5); } } // cellstats // might be modified by mpLbm //mpParts->setStart( mGeoStart );? mpParts->setEnd( mGeoEnd );? mpParts->setStart( mpLbm->getGeoStart() ); mpParts->setEnd( mpLbm->getGeoEnd() ); mpParts->setCastShadows( false ); mpParts->setReceiveShadows( false ); mpParts->searchMaterial( glob->getMaterials() ); // this has to be inited here - before, the values might be unknown IsoSurface *surf = mpLbm->getSurfaceGeoObj(); if(surf) { surf->setName( "final" ); // final surface mesh // warning - this might cause overwriting effects for multiple sims and geom dump... surf->setCastShadows( true ); surf->setReceiveShadows( false ); surf->searchMaterial( glob->getMaterials() ); if(mShowSurface) mObjects.push_back( surf ); } #ifdef ELBEEM_PLUGIN mShowParticles=1; // for e.g. dumping #endif // ELBEEM_PLUGIN if((mpLbm->getGenerateParticles()>0.0)||(mpParts->getNumInitialParticles()>0)) { mShowParticles=1; mpParts->setDumpParts(true); } //debMsgStd("SimulationObject::init",DM_NOTIFY,"Using envvar ELBEEM_DUMPPARTICLE to set mShowParticles, DEBUG!",1); //} // DEBUG ENABLE!!!!!!!!!! if(mShowParticles) { mObjects.push_back(mpParts); } // add objects to display for debugging (e.g. levelset particles) vector<ntlGeometryObject *> debugObjs = mpLbm->getDebugObjects(); for(size_t i=0;i<debugObjs.size(); i++) { debugObjs[i]->setCastShadows( false ); debugObjs[i]->setReceiveShadows( false ); debugObjs[i]->searchMaterial( glob->getMaterials() ); mObjects.push_back( debugObjs[i] ); debMsgStd("SimulationObject::init",DM_NOTIFY,"Added debug obj "<<debugObjs[i]->getName(), 10 ); } return 0; }
void Object::loadFromXml(tinyxml2::XMLElement* objectElement) { std::vector<std::string> attributesObject, attributesSymmetry, attributesPoint, valuesObject, valuesSymmetry; std::vector<float> valuesPoint; attributesObject.push_back("ID"); attributesObject.push_back("name"); attributesSymmetry.push_back("type"); attributesPoint.push_back("x"); attributesPoint.push_back("y"); attributesPoint.push_back("z"); //getting attributes for object getAttributeList(valuesObject, attributesObject, objectElement); objectName_=valuesObject.at(1); objectID_=charArrayToInt(valuesObject.at(0).c_str()); //getting attributes for object -only one symmetry per object tinyxml2::XMLElement* symmetryPtr = objectElement->FirstChildElement("symmetry"); if(symmetryPtr != NULL) { getAttributeList(valuesSymmetry, attributesSymmetry, symmetryPtr); } else { std::cout << "[Error] Wrong XML Element Name: symmetry" << std::endl; exit(EXIT_FAILURE); } //Mapping strings to enum type, see util getSymmetryTypeFromString(objectSymmetry_.symmetryType,valuesSymmetry.at(0)); //getting attributes for the layers and stuff, several cases and element, looping tinyxml2::XMLElement* layerOrAxisPtr = symmetryPtr->FirstChildElement(); tinyxml2::XMLElement* pointPtr = NULL; switch (objectSymmetry_.symmetryType) { case SINGLEPLANE: { SinglePlane singlePlane; //actual single plane in the loop; int n =0; int m = 0; //Outer Loop for (; layerOrAxisPtr; layerOrAxisPtr=layerOrAxisPtr->NextSiblingElement() ) { pointPtr = layerOrAxisPtr->FirstChildElement("point"); //std::cout << "[Debug 50]:Outer Loop " << "\n" << std::flush; //std::cout << "[Debug 50]:Pointer Value " << layerOrAxisPtr->Name() << "\n" << std::flush; m=0; //Inner Loop - getting the full layer or axis for(; pointPtr; pointPtr=pointPtr->NextSiblingElement() ){ getAttributeList(valuesPoint, attributesPoint, pointPtr); //std::cout << "[Debug 60]:Inner Loop " << "\n" << std::flush; //std::cout << "[Debug 60]:Pointer Value " << pointPtr->Name() << "\n" << std::flush; //std::cout << "[Debug 60]: m " << m << "\n" << std::flush; //std::cout << "[Debug 60]: n " << n << "\n" << std::flush; //std::cout << "[Debug 60]: ValuePoint(1) " << valuesPoint.at(1) << "\n" << std::flush; if (m==0) singlePlane.plane1.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) singlePlane.plane1.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==2) singlePlane.plane1.point3 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); m++; valuesPoint.resize(0); //erasing content } //In Outer Loop n++; } singlePlane.scale(0.001); objectSymmetry_.symmetryData = singlePlane; } break; case DOUBLEPLANE: { DoublePlane doublePlane; //actual single plane in the loop; int n =0; int m = 0; //Outer Loop for (; layerOrAxisPtr; layerOrAxisPtr =layerOrAxisPtr->NextSiblingElement("layer") ) { pointPtr = layerOrAxisPtr->FirstChildElement("point"); m=0; //Inner Loop - getting the full layer or axis for(; pointPtr; pointPtr=pointPtr->NextSiblingElement("point") ){ getAttributeList(valuesPoint, attributesPoint, pointPtr); if (n==0) { if (m==0) doublePlane.plane1.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) doublePlane.plane1.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==2) doublePlane.plane1.point3 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); } else if (n==1){ if (m==0) doublePlane.plane2.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) doublePlane.plane2.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==2) doublePlane.plane2.point3 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); } m++; valuesPoint.resize(0); //erasing content } //In Outer Loop n++; } doublePlane.scale(0.001); objectSymmetry_.symmetryData = doublePlane; } break; case TRIPLEPLANE: { TriplePlane triplePlane; //actual single plane in the loop; int n =0; int m = 0; //Outer Loop for (; layerOrAxisPtr; layerOrAxisPtr=layerOrAxisPtr->NextSiblingElement("layer") ) { pointPtr = layerOrAxisPtr->FirstChildElement("point"); m=0; //Inner Loop - getting the full layer or axis for(; pointPtr; pointPtr=pointPtr->NextSiblingElement("point") ){ getAttributeList(valuesPoint, attributesPoint, pointPtr); if (n==0) { if (m==0) triplePlane.plane1.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) triplePlane.plane1.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==2) triplePlane.plane1.point3 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); } else if (n==1){ if (m==0) triplePlane.plane2.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) triplePlane.plane2.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==2) triplePlane.plane2.point3 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); } else if (n==2) { if (m==0) triplePlane.plane3.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) triplePlane.plane3.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==2) triplePlane.plane3.point3 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); } m++; valuesPoint.resize(0); //erasing content } //In Outer Loop n++; } triplePlane.scale(0.001); objectSymmetry_.symmetryData = triplePlane; } break; case AXIAL: { Axial axial; //actual single plane in the loop; int n =0; int m = 0; //Outer Loop for (; layerOrAxisPtr; layerOrAxisPtr=layerOrAxisPtr->NextSiblingElement("axis") ) { pointPtr = layerOrAxisPtr->FirstChildElement("point"); m=0; //Inner Loop - getting the full layer or axis for(; pointPtr; pointPtr = pointPtr->NextSiblingElement("point") ){ getAttributeList(valuesPoint, attributesPoint, pointPtr); std::cout << "[Debug 60]: ValuePoint(1) " << valuesPoint.at(1) << "\n" << std::flush; if (m==0) axial.axis1.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) axial.axis1.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); m++; valuesPoint.resize(0); //erasing content } //In Outer Loop n++; } axial.scale(0.001); objectSymmetry_.symmetryData = axial; } break; case AXIALSINGLEPLANE: { AxialSinglePlane axialSinglePlane; //actual single plane in the loop; Layer3D layer; Axis3D axis; int n =0; int m = 0; //Outer Loop for axis layerOrAxisPtr = symmetryPtr->FirstChildElement("axis"); for (; layerOrAxisPtr; layerOrAxisPtr=layerOrAxisPtr->NextSiblingElement("axis") ) { pointPtr = layerOrAxisPtr->FirstChildElement("point"); m=0; //Inner Loop - getting the full layer or axis for(; pointPtr; pointPtr=pointPtr->NextSiblingElement("point") ){ getAttributeList(valuesPoint, attributesPoint, pointPtr); if (m==0) axis.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) axis.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); m++; valuesPoint.resize(0); //erasing content } //In Outer Loop n++; } //Outer Loop for layer n=0; m=0; layerOrAxisPtr = symmetryPtr->FirstChildElement("layer"); for (; layerOrAxisPtr; layerOrAxisPtr=layerOrAxisPtr->NextSiblingElement("layer") ) { pointPtr = layerOrAxisPtr->FirstChildElement("point"); m=0; //Inner Loop - getting the full layer or axis for(; pointPtr; pointPtr=pointPtr->NextSiblingElement("point") ){ getAttributeList(valuesPoint, attributesPoint, pointPtr); if (m==0) layer.point1 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==1) layer.point2 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); else if(m==2) layer.point3 << valuesPoint.at(0), valuesPoint.at(1), valuesPoint.at(2); m++; valuesPoint.resize(0); //erasing content } //In Outer Loop n++; } axialSinglePlane.axis1 = axis; axialSinglePlane.plane1 = layer; axialSinglePlane.scale(0.001); objectSymmetry_.symmetryData = axialSinglePlane; } break; default: std::cout << "[Error] Objectsymmetry not correctly defined on XML, exiting!\n"; exit(EXIT_FAILURE); break; } }