void RenderSector::Push(const Model &model, const glm::vec3 &pos) { // Если сектор надо перестроить и модель статическая - перестраиваем сектор. if (mIsNeedBuild && model.GetType() == Model::Static) { auto &dst = mModel.GetMesh(); const auto &src = model.GetMesh(); if (dst->Empty()) { mModel.SetTexture(model.GetTexture()); } if (mModel.GetTexture() == model.GetTexture()) { size_t size = dst->SizeVertex(); dst->Push(*src); for (size_t i = size; i < dst->SizeVertex(); ++i) { dst->Vertex(i).vertex += pos; } } else { LOG(warning) << "Батчинг меша в секторе пропущен. Текстуры не совпадают."; } } }
void DLModel ( const char* aModelFile, ModelData* aModelDataStruct, Problem *problem ) { // Local variables ParseModelHelper parseModelHelper = ParseModelHelper(); int PhaseIds[] = {-1, 1, 0, 0, 0, 0}; UInt numFunctions = 0; UInt modelId = aModelDataStruct->GetModelId(); UInt meshId = aModelDataStruct->GetMeshId(); UInt numSolnWriters = aModelDataStruct->mSolutionData.size(); /// MODEL -------------------------------------------------------- Model* model = problem->CreateModel ( aModelDataStruct,modelId,meshId,0,0,0,0, 0,0,0,numSolnWriters); Mesh* msh = model->GetMesh(); parseModelHelper.SetNumLs(model,1); parseModelHelper.SetMainPhaseFlags(model,PhaseIds,2); /// Functions UInt numE[3] = {0,0,0}; UInt *NodeIndices=NULL, *NodeIds=NULL; numFunctions = parseModelHelper.GetAllNodesInfo(msh,NodeIndices,NodeIds); PropFunction** PropFunctionPtrs = (PropFunction**) alloca(sizeof(PropFunction*)*numFunctions); Real funcVal = 1.0; const enum FunctionVarType funcVarType = FUNC_VAR_DESVAR; for ( UInt in = 0; in < numFunctions; ++in ) PropFunctionPtrs[in] = model->CreatePropFunction(NodeIds[in],FUNCTION_CONSTANT,&funcVarType, numE,&funcVal); /// Node Properties /// Node Properties std::vector<UInt> NpIds; NpIds.push_back(10), NpIds.push_back(11); model->CreateNodeProperty ( NpIds[0],NP_STRUC ); NodeProperty* nodeProp = model->CreateNodeProperty ( NpIds[1],NP_GENERIC ); nodeProp->InitializeProperty(NP_LS,0, numFunctions, NodeIndices, numFunctions, PropFunctionPtrs ); /// Element Properties block std::vector<UInt> BlkEpIds; BlkEpIds.push_back(20); ElementProperty* elemProp = model->CreateElementProperty ( BlkEpIds[0],EP_STRUC ); elemProp->SetDirective( (UInt) ED_STRUC_DAMP_TYPE,DIRECTIVE_FALSE ); elemProp->InitializeProperty( EP_STRUC_ALPHAD, 0.0, 1, NULL, 1, NULL ); elemProp->InitializeProperty( EP_STRUC_BETAD , 0.0, 1, NULL, 1, NULL ); elemProp->InitializeProperty( EP_THICKNESS , 1.0, 1, NULL, 1, NULL ); elemProp->InitializeProperty( EP_INTERFACE_PARAM, 1.0e+04, 1, NULL, 1, NULL ); elemProp->SetDirective( (UInt) ED_ADD_SPRINGS,DIRECTIVE_TRUE ); elemProp->InitializeProperty( EP_SPRINGS_PARAM, 1.0e-06, 1, NULL, 1, NULL ); // std::vector<UInt> SSetEpIds; // SSetEpIds.push_back(21); // elemProp = model->CreateElementProperty ( SSetEpIds[0],EP_STRUCSURF ); // elemProp->InitializeProperty( EP_STRUC_YTRAC ,-2.0e-2 , 1, NULL, 1, NULL ); // elemProp->InitializeProperty( EP_INTERFACE_PARAM, 1.0e+04, 1, NULL, 1, NULL ); /// Materials Block std::vector<UInt> BlkMatIds; BlkMatIds.push_back(30); Material* material = model->CreateMaterial ( BlkMatIds[0], MATERIAL_STRUC_ELASTIC_ISOTROPIC); material->InitializeProperty( MP_THERM_RHO, 1.0, 1, NULL, 1, NULL ); material->InitializeProperty( MP_STRUC_EX, 1.0, 1, NULL, 1, NULL ); material->InitializeProperty( MP_STRUC_PRXY, 0.2, 1, NULL, 1, NULL ); /// Nodes if (sXfemBlockElemType == NON_XFEM_ELEMENT) parseModelHelper.CreateAllNodes(model,NpIds); else parseModelHelper.CreateAllNodes(model,NpIds); /// Elements Block enum ElementType BlockElemTypes[] = {STRUC_LIN_QUAD4,GNRC_DIFF}; parseModelHelper.CreateElementsByBaseSetId(model,sBSetIds[0],NON_COUPLED_ELEMENT,NON_IC_ELEMENT,sXfemBlockElemType,BlockElemTypes,BlkEpIds,BlkMatIds); /// SideSet Elements // enum ElementType SSetElemType = STRUC_SURF_BAR2; // parseModelHelper.CreateElementsBySideSetId(model,sSSetIds[sLoadNSSetIndx],NON_COUPLED_ELEMENT,NON_IC_ELEMENT,NON_XFEM_ELEMENT,&SSetElemType,SSetEpIds,BlkMatIds); /// Finalize Model parseModelHelper.FinalizeModel(model,STATIC_XFEM_INTERFACE); /// MPC Block model->SetMpcDofs(); /// Dirichlet Conditions UInt phase1Ind = 0; UInt phase2Ind = 1; UInt phaseEnrichInd = -1; parseModelHelper.ApplyNodeConditionToSSetByIdXFem( model, sSSetIds[sAnchNSSetIndx], DIRICHLET, REGULAR_DOF, UX, phase1Ind, phaseEnrichInd, 0.0); parseModelHelper.ApplyNodeConditionToSSetByIdXFem( model, sSSetIds[sAnchNSSetIndx], DIRICHLET, REGULAR_DOF, UY, phase1Ind, phaseEnrichInd, 0.0); parseModelHelper.ApplyNodeConditionToAllXFem( model, DIRICHLET, REGULAR_DOF, UX, phase2Ind, phaseEnrichInd, 0.0); parseModelHelper.ApplyNodeConditionToAllXFem( model, DIRICHLET, REGULAR_DOF, UY, phase2Ind, phaseEnrichInd, 0.0); parseModelHelper.ApplyNodeConditionToSSetByIdXFem( model, sSSetIds[sLoadNSSetIndx], NEUMANN, REGULAR_DOF, UY, phase1Ind, phaseEnrichInd, -2.0e-2 ); parseModelHelper.ApplyNodeConditionToAllXFem( model, IDISP, REGULAR_DOF, UX, phase1Ind, phaseEnrichInd, 0.0); parseModelHelper.ApplyNodeConditionToAllXFem( model, IDISP, REGULAR_DOF, UY, phase1Ind, phaseEnrichInd, 0.0); parseModelHelper.ApplyNodeConditionToAllXFem( model, IDISP, REGULAR_DOF, UX, phase2Ind, phaseEnrichInd, 0.0); parseModelHelper.ApplyNodeConditionToAllXFem( model, IDISP, REGULAR_DOF, UY, phase2Ind, phaseEnrichInd, 0.0); /* model->CreateXFemDirichletCondition(UX , PhaseIds[0], sSSetIds[sAnchNSSetIndx], SIDESET_VAR, 0.0); model->CreateXFemDirichletCondition(UY , PhaseIds[0], sSSetIds[sAnchNSSetIndx], SIDESET_VAR, 0.0); model->CreateXFemDirichletCondition(UX , PhaseIds[1], 0 , GLOBAL_VAR , 0.0); model->CreateXFemDirichletCondition(UY , PhaseIds[1], 0 , GLOBAL_VAR , 0.0); /// Initial Conditions Block model->CreateXFemInitialCondition(UX , PhaseIds[0], 0.0); model->CreateXFemInitialCondition(UX , PhaseIds[1], 0.0); model->CreateXFemInitialCondition(UY , PhaseIds[0], 0.0); model->CreateXFemInitialCondition(UY , PhaseIds[1], 0.0);*/ }