//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::updateFormationNamesData() { RigGeoMechCaseData* rigCaseData = geoMechData(); if(rigCaseData && rigCaseData->femPartResults()) { if(activeFormationNames()) { rigCaseData->femPartResults()->setActiveFormationNames(activeFormationNames()->formationNamesData()); } else { rigCaseData->femPartResults()->setActiveFormationNames(nullptr); } std::vector<Rim3dView*> views = this->views(); for(Rim3dView* view : views) { RimGeoMechView* geomView = dynamic_cast<RimGeoMechView*>(view); if ( geomView && geomView->isUsingFormationNames() ) { if ( !activeFormationNames() ) { if ( geomView->cellResult()->resultPositionType() == RIG_FORMATION_NAMES ) { geomView->cellResult()->setResultAddress(RigFemResultAddress(RIG_FORMATION_NAMES, "", "")); geomView->cellResult()->updateConnectedEditors(); } RimGeoMechPropertyFilterCollection* eclFilColl = geomView->geoMechPropertyFilterCollection(); for ( RimGeoMechPropertyFilter* propFilter : eclFilColl->propertyFilters ) { if ( propFilter->resultDefinition()->resultPositionType() == RIG_FORMATION_NAMES ) { propFilter->resultDefinition()->setResultAddress(RigFemResultAddress(RIG_FORMATION_NAMES, "", "")); } } } RimGeoMechPropertyFilterCollection* eclFilColl = geomView->geoMechPropertyFilterCollection(); for ( RimGeoMechPropertyFilter* propFilter : eclFilColl->propertyFilters ) { if ( propFilter->resultDefinition->resultPositionType() == RIG_FORMATION_NAMES ) { propFilter->setToDefaultValues(); propFilter->updateConnectedEditors(); } } geomView->cellResult()->updateConnectedEditors(); view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); geomView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::closeSelectedElementPropertyFiles() { std::sort(m_elementPropertyFileNameIndexUiSelection.v().begin(), m_elementPropertyFileNameIndexUiSelection.v().end(), descendingComparator()); std::vector<QString> filesToClose; for (size_t idx : m_elementPropertyFileNameIndexUiSelection.v()) { filesToClose.push_back(m_elementPropertyFileNames.v().at(idx).path()); m_elementPropertyFileNames.v().erase(m_elementPropertyFileNames.v().begin() + idx); } m_elementPropertyFileNameIndexUiSelection.v().clear(); std::vector<RigFemResultAddress> addressesToDelete; if (m_geoMechCaseData.notNull()) { addressesToDelete = geoMechData()->femPartResults()->removeElementPropertyFiles(filesToClose); } for (RimGeoMechView* view : geoMechViews()) { for (RigFemResultAddress address : addressesToDelete) { if (address == view->cellResultResultDefinition()->resultAddress()) { view->cellResult()->setResultAddress(RigFemResultAddress()); } for (RimGeoMechPropertyFilter* propertyFilter : view->geoMechPropertyFilterCollection()->propertyFilters()) { if (address == propertyFilter->resultDefinition->resultAddress()) { propertyFilter->resultDefinition->setResultAddress(RigFemResultAddress()); } } } view->loadDataAndUpdate(); } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::vector< RigFemResultAddress> RigFemPartResultsCollection::getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr) { std::map<std::string, std::vector<std::string> > fieldAndComponentNames; switch (resVarAddr.resultPosType) { case RIG_NODAL: fieldAndComponentNames = m_readerInterface->scalarNodeFieldAndComponentNames(); break; case RIG_ELEMENT_NODAL: fieldAndComponentNames = m_readerInterface->scalarElementNodeFieldAndComponentNames(); break; case RIG_INTEGRATION_POINT: fieldAndComponentNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); break; } std::vector< RigFemResultAddress> resAddressToComponents; std::map<std::string, std::vector<std::string> >::iterator fcIt = fieldAndComponentNames.find(resVarAddr.fieldName); if (fcIt != fieldAndComponentNames.end()) { std::vector<std::string> compNames = fcIt->second; if (resVarAddr.componentName != "") // If we did not request a particular component, do not add the components { for (size_t cIdx = 0; cIdx < compNames.size(); ++cIdx) { resAddressToComponents.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, compNames[cIdx])); } } if (compNames.size() == 0) // This is a scalar field. Add one component named "" { CVF_ASSERT(resVarAddr.componentName == ""); resAddressToComponents.push_back(resVarAddr); } } return resAddressToComponents; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr) { if (resVarAddr.fieldName == "NE") { RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "E", resVarAddr.componentName)); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); int frameCount = srcDataFrames->frameCount(); for (int fIdx = 0; fIdx < frameCount; ++fIdx) { const std::vector<float>& srcFrameData = srcDataFrames->frameData(fIdx); std::vector<float>& dstFrameData = dstDataFrames->frameData(fIdx); size_t valCount = srcFrameData.size(); dstFrameData.resize(valCount); for (size_t vIdx = 0; vIdx < valCount; ++vIdx) { dstFrameData[vIdx] = -srcFrameData[vIdx]; } } return dstDataFrames; } if ((resVarAddr.fieldName == "SE") && !(resVarAddr.componentName == "S1" || resVarAddr.componentName == "S2" || resVarAddr.componentName == "S3" )) { RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S", resVarAddr.componentName)); RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR", "")); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); const RigFemPart * femPart = m_femParts->part(partIndex); float inf = std::numeric_limits<float>::infinity(); int frameCount = srcDataFrames->frameCount(); for (int fIdx = 0; fIdx < frameCount; ++fIdx) { const std::vector<float>& srcFrameData = srcDataFrames->frameData(fIdx); std::vector<float>& dstFrameData = dstDataFrames->frameData(fIdx); size_t valCount = srcFrameData.size(); dstFrameData.resize(valCount); const std::vector<float>& srcPORFrameData = srcPORDataFrames->frameData(fIdx); int nodeIdx = 0; for (size_t vIdx = 0; vIdx < valCount; ++vIdx) { nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(vIdx); float por = srcPORFrameData[nodeIdx]; if (por == inf) dstFrameData[vIdx] = inf; else dstFrameData[vIdx] = -srcFrameData[vIdx]; } } return dstDataFrames; } if ( (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST" ) && (resVarAddr.componentName == "S1" || resVarAddr.componentName == "S2" || resVarAddr.componentName == "S3" )) { RigFemScalarResultFrames * s11Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S11")); RigFemScalarResultFrames * s22Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S22")); RigFemScalarResultFrames * s33Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S33")); RigFemScalarResultFrames * s12Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S12")); RigFemScalarResultFrames * s13Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S13")); RigFemScalarResultFrames * s23Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S23")); RigFemScalarResultFrames * s1Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1")); RigFemScalarResultFrames * s2Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2")); RigFemScalarResultFrames * s3Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3")); int frameCount = s11Frames->frameCount(); for (int fIdx = 0; fIdx < frameCount; ++fIdx) { const std::vector<float>& s11 = s11Frames->frameData(fIdx); const std::vector<float>& s22 = s22Frames->frameData(fIdx); const std::vector<float>& s33 = s33Frames->frameData(fIdx); const std::vector<float>& s12 = s12Frames->frameData(fIdx); const std::vector<float>& s13 = s13Frames->frameData(fIdx); const std::vector<float>& s23 = s23Frames->frameData(fIdx); std::vector<float>& s1 = s1Frames->frameData(fIdx); std::vector<float>& s2 = s2Frames->frameData(fIdx); std::vector<float>& s3 = s3Frames->frameData(fIdx); size_t valCount = s11.size(); s1.resize(valCount); s2.resize(valCount); s3.resize(valCount); for (size_t vIdx = 0; vIdx < valCount; ++vIdx) { caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx] ); cvf::Vec3f principals = T.calculatePrincipals(NULL); s1[vIdx] = principals[0]; s2[vIdx] = principals[1]; s3[vIdx] = principals[2]; } } RigFemScalarResultFrames* requestedPrincipal = this->findOrLoadScalarResult(partIndex,resVarAddr); return requestedPrincipal; } if ( resVarAddr.fieldName == "ST" && ( resVarAddr.componentName == "S11" || resVarAddr.componentName == "S22" || resVarAddr.componentName == "S33" )) { RigFemScalarResultFrames * srcNSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S", resVarAddr.componentName)); RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR", "")); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); const RigFemPart * femPart = m_femParts->part(partIndex); int frameCount = srcNSDataFrames->frameCount(); for (int fIdx = 0; fIdx < frameCount; ++fIdx) { const std::vector<float>& srcNSFrameData = srcNSDataFrames->frameData(fIdx); const std::vector<float>& srcPORFrameData = srcPORDataFrames->frameData(fIdx); std::vector<float>& dstFrameData = dstDataFrames->frameData(fIdx); size_t valCount = srcNSFrameData.size(); dstFrameData.resize(valCount); int nodeIdx = 0; for (size_t vIdx = 0; vIdx < valCount; ++vIdx) { nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(vIdx); float por = srcPORFrameData[nodeIdx]; if (por == std::numeric_limits<float>::infinity()) por = 0.0f; dstFrameData[vIdx] = -srcNSFrameData[vIdx] + por; } } return dstDataFrames; } if ( resVarAddr.fieldName == "ST" && ( resVarAddr.componentName == "S12" || resVarAddr.componentName == "S13" || resVarAddr.componentName == "S23" )) { RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S", resVarAddr.componentName)); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); const RigFemPart * femPart = m_femParts->part(partIndex); int frameCount = srcSDataFrames->frameCount(); for (int fIdx = 0; fIdx < frameCount; ++fIdx) { const std::vector<float>& srcNSFrameData = srcSDataFrames->frameData(fIdx); std::vector<float>& dstFrameData = dstDataFrames->frameData(fIdx); size_t valCount = srcNSFrameData.size(); dstFrameData.resize(valCount); int nodeIdx = 0; for (size_t vIdx = 0; vIdx < valCount; ++vIdx) { dstFrameData[vIdx] = -srcNSFrameData[vIdx]; } } return dstDataFrames; } if (resVarAddr.fieldName == "ST" && resVarAddr.componentName == "") { // Create and return an empty result return m_femPartResults[partIndex]->createScalarResult(resVarAddr); } if (resVarAddr.fieldName == "Gamma" && ( resVarAddr.componentName == "Gamma1" || resVarAddr.componentName == "Gamma2" || resVarAddr.componentName == "Gamma3" || resVarAddr.componentName == "Gamma11" || resVarAddr.componentName == "Gamma22" || resVarAddr.componentName == "Gamma33" )) { RigFemScalarResultFrames * srcDataFrames = NULL; if (resVarAddr.componentName == "Gamma1"){ srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S1")); }else if (resVarAddr.componentName == "Gamma2"){ srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S2")); }else if (resVarAddr.componentName == "Gamma3"){ srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S3")); }else if (resVarAddr.componentName == "Gamma11"){ srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S11")); }else if (resVarAddr.componentName == "Gamma22"){ srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S22")); }else if (resVarAddr.componentName == "Gamma33"){ srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "ST", "S33")); } RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR", "")); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); const RigFemPart * femPart = m_femParts->part(partIndex); int frameCount = srcDataFrames->frameCount(); float inf = std::numeric_limits<float>::infinity(); for (int fIdx = 0; fIdx < frameCount; ++fIdx) { const std::vector<float>& srcSTFrameData = srcDataFrames->frameData(fIdx); const std::vector<float>& srcPORFrameData = srcPORDataFrames->frameData(fIdx); std::vector<float>& dstFrameData = dstDataFrames->frameData(fIdx); size_t valCount = srcSTFrameData.size(); dstFrameData.resize(valCount); int nodeIdx = 0; for (size_t vIdx = 0; vIdx < valCount; ++vIdx) { nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(vIdx); float por = srcPORFrameData[nodeIdx]; if (por == inf || abs(por) < 0.01e6) dstFrameData[vIdx] = inf; else dstFrameData[vIdx] = srcSTFrameData[vIdx]/por; } } return dstDataFrames; } if (resVarAddr.fieldName == "Gamma" && resVarAddr.componentName == "") { // Create and return an empty result return m_femPartResults[partIndex]->createScalarResult(resVarAddr); } return NULL; }