Skip to content

Commit

Permalink
Fault reactivation: OMP parallelization.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Feb 5, 2024
1 parent 0de8f0a commit 892b1d1
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "RimFaultReactivationDataAccessorVoidRatio.h"
#include "RimFaultReactivationEnums.h"
#include "RimFaultReactivationModel.h"
#include <limits>

//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -179,20 +180,26 @@ std::vector<double> RimFaultReactivationDataAccess::extractModelData( const RigF
CAF_ASSERT( it != borderSurfaceElements.end() && "Sea bed border surface does not exist" );
std::set<unsigned int> seabedElements( it->second.begin(), it->second.end() );

std::vector<double> values;

if ( nodeProperties.contains( property ) )
{
for ( auto& node : grid->dataNodes() )
int numNodes = grid->dataNodes().size();
std::vector<double> values( numNodes, std::numeric_limits<double>::infinity() );

#pragma omp parallel for
for ( int nodeIndex = 0; nodeIndex < numNodes; nodeIndex++ )
{
double value = accessor->valueAtPosition( node, model, gridPart );
values.push_back( value );
double value = accessor->valueAtPosition( grid->dataNodes()[nodeIndex], model, gridPart );
values[nodeIndex] = value;
}
return values;
}
else
{
size_t numElements = grid->elementIndices().size();
for ( size_t elementIndex = 0; elementIndex < numElements; elementIndex++ )
int numElements = grid->elementIndices().size();
std::vector<double> values( numElements, std::numeric_limits<double>::infinity() );

#pragma omp parallel for
for ( int elementIndex = 0; elementIndex < numElements; elementIndex++ )
{
std::vector<cvf::Vec3d> corners = grid->elementDataCorners( elementIndex );

Expand All @@ -203,13 +210,12 @@ std::vector<double> RimFaultReactivationDataAccess::extractModelData( const RigF
double topDepth = computeAverageDepth( corners, { 0, 1, 2, 3 } ) - topDepthAdjust;
double bottomDepth = computeAverageDepth( corners, { 4, 5, 6, 7 } );

cvf::Vec3d position = RigCaseToCaseCellMapperTools::calculateCellCenter( corners.data() );
double value = accessor->valueAtPosition( position, model, gridPart, topDepth, bottomDepth, elementIndex );
values.push_back( value );
cvf::Vec3d position = RigCaseToCaseCellMapperTools::calculateCellCenter( corners.data() );
double value = accessor->valueAtPosition( position, model, gridPart, topDepth, bottomDepth, elementIndex );
values[elementIndex] = value;
}
return values;
}

return values;
}

return {};
Expand Down

0 comments on commit 892b1d1

Please sign in to comment.