Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement EDFM loading from VTK #3510

Open
wants to merge 57 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d77d082
initial embedded surface block abc
ouassimkh Sep 6, 2023
35196c8
minor change
ouassimkh Sep 7, 2023
2135a21
start concrete implementation
ouassimkh Sep 13, 2023
7eb79a5
add the cpp
ouassimkh Sep 13, 2023
b20dd27
add embedded surfaces to CellBlockManager
ouassimkh Sep 15, 2023
738c14a
this should not be commited
Sep 29, 2023
2fcdeed
upate cellBlock Manger and embedded Ruface block
ouassimkh Sep 27, 2023
186a222
Correct edfm to cell type
ouassimkh Oct 26, 2023
2401cc7
corrections
ouassimkh Apr 16, 2024
e2346e7
create edfm patches in bulk
ouassimkh Apr 9, 2024
c42b37f
small changes
ouassimkh Apr 17, 2024
55239bd
add flag to enable experimentation
ouassimkh Apr 18, 2024
4b2363e
missed files
ouassimkh Apr 18, 2024
0fde8c6
add bulk edfm fracs
ouassimkh Apr 26, 2024
dd8d49e
All is running
ouassimkh Apr 29, 2024
2e43180
uncrustify pass
ouassimkh Apr 29, 2024
cd555e0
start VTK edfm support
ouassimkh Jun 4, 2024
041d290
Finish EDFM loading from VTK (no parallel)
ouassimkh Jun 24, 2024
3bda862
builds after master rebase issues
ouassimkh Oct 31, 2024
256efee
working serial run
ouassimkh Nov 5, 2024
2d6583d
clearning
ouassimkh Nov 7, 2024
8d52abc
cleraning
ouassimkh Nov 8, 2024
c718d96
bug
ouassimkh Nov 8, 2024
ba87177
uncrustify pass
ouassimkh Nov 8, 2024
6d70f05
remove comments
ouassimkh Nov 11, 2024
c4a913b
use faceBlockName + some fixes for build (#3436)
paveltomin Nov 11, 2024
584a601
add edfm vtk example
ouassimkh Nov 13, 2024
29a20e8
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
paveltomin Nov 20, 2024
7b9014e
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
rrsettgast Nov 22, 2024
31118bb
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
paveltomin Dec 2, 2024
5caf9aa
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
paveltomin Dec 9, 2024
c84e27a
build fix
Dec 9, 2024
b4a5df4
remove
Dec 10, 2024
cec6ed2
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
paveltomin Dec 12, 2024
b079426
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
paveltomin Dec 16, 2024
3e0357e
doxygen fix
Dec 16, 2024
1388970
fix one crash and introduce another
Dec 16, 2024
ef54e9c
just to see if test fail because of this
paveltomin Dec 16, 2024
12e1747
fix old edfm cases
Dec 17, 2024
9716f90
Merge branch 'Feature/ouassim/edfm_loader_new' of https://github.com/…
Dec 17, 2024
a742215
chansing the paralllel issue
Dec 17, 2024
b3cee3b
fix global to local mapping
Dec 19, 2024
b7cd2b8
Update edfm_vtk_fractures.vtu
paveltomin Dec 19, 2024
71ec173
code style
Dec 19, 2024
4fb1ac9
Merge branch 'Feature/ouassim/edfm_loader_new' of https://github.com/…
Dec 19, 2024
7784585
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
paveltomin Dec 23, 2024
4150280
doxygen fix
Dec 23, 2024
c3d501a
Update VTKUtilities.hpp
paveltomin Dec 26, 2024
8fc88c1
Update EmbeddedSurfaceBlock.hpp
paveltomin Dec 26, 2024
8384539
Merge branch 'develop' into Feature/ouassim/edfm_loader_new
paveltomin Jan 8, 2025
1bf96de
Merge remote-tracking branch 'origin/develop' into ouassim/edfm_loader
CusiniM Jan 13, 2025
b1fa4c4
move creation of EmbeddedFractures upon input.
CusiniM Jan 15, 2025
21f2e06
wip: move things around add useful comments.
CusiniM Jan 15, 2025
da7b7fa
moved all needed functions.
CusiniM Jan 16, 2025
f1555ab
Fixed CI computation.
CusiniM Jan 16, 2025
1ecec46
fixed compilation issues.
CusiniM Jan 16, 2025
e49b685
Merge branch 'develop' into ouassim/edfm_loader
paveltomin Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/coreComponents/mainInterface/ProblemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ void ProblemManager::generateMesh()
domain.setupCommunications( useNonblockingMPI );
domain.outputPartitionInformation();

// Create Embedded fractures here.
generateEmbeddedFractures();

domain.forMeshBodies( [&]( MeshBody & meshBody )
{
if( meshBody.hasGroup( keys::particleManager ) )
Expand Down Expand Up @@ -728,6 +731,47 @@ void ProblemManager::generateMesh()

}

void ProblemManager::generateEmbeddedFractures()
{
DomainPartition & domain = getDomainPartition();
MeshManager & meshManager = this->getGroup< MeshManager >( groupKeys.meshManager );

meshManager.generateEmbeddedFractures( domain );

MeshBody & meshBody = domain.getMeshBody( 0 );
CellBlockManagerABC const & cellBlockManager = meshBody.getCellBlockManager();
Group const & embSurfBlocks = cellBlockManager.getEmbeddedSurfaceBlocks();
string const & faceBlockName = embeddedSurfaceRegion.getFaceBlockName();

if( embSurfBlocks.hasGroup( faceBlockName ))
{
EmbeddedSurfaceBlockABC const & embSurf = embSurfBlocks.getGroup< EmbeddedSurfaceBlockABC >( faceBlockName );

elemManager.forElementSubRegionsComplete< CellElementSubRegion >( [&]( localIndex const er,
localIndex const esr,
ElementRegionBase &,
CellElementSubRegion & subRegion )
{
FixedOneToManyRelation const & cellToEdges = subRegion.edgeList();

embeddedSurfaceSubRegion.copyFromEmbeddedSurfaceBlock( er,
esr,
nodeManager,
embSurfNodeManager,
edgeManager,
cellToEdges,
embSurf );

// Add all the fracture information to the CellElementSubRegion
for( localIndex edfmIndex=0; edfmIndex < embSurf.numEmbeddedSurfElem(); ++edfmIndex )
{
localIndex cellIndex = embSurf.getEmbeddedSurfElemTo3dElem().toCellIndex[edfmIndex][0];
subRegion.addFracturedElement( cellIndex, edfmIndex );
newObjects.newElements[ {embeddedSurfaceRegion.getIndexInParent(), embeddedSurfaceSubRegion.getIndexInParent()} ].insert( edfmIndex );
}
} ); // end loop over subregions
}
}

void ProblemManager::importFields()
{
Expand Down
23 changes: 7 additions & 16 deletions src/coreComponents/mesh/EmbeddedSurfaceSubRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
#include "BufferOps.hpp"
#include "mesh/MeshFields.hpp"


#include "mainInterface/GeosxState.hpp"
#include "mainInterface/ProblemManager.hpp"
#include "mesh/DomainPartition.hpp"

namespace geos
{
using namespace dataRepository;
Expand Down Expand Up @@ -345,14 +340,13 @@ array1d< localIndex > EmbeddedSurfaceSubRegion::getEdfmNodeParentEdgeIndex( Arra
return parentEdgeIndex;
}

bool EmbeddedSurfaceSubRegion::addAllEmbeddedSurfaces(
localIndex const regionIndex,
localIndex const subRegionIndex,
NodeManager const & nodeManager,
EmbeddedSurfaceNodeManager & embSurfNodeManager,
EdgeManager const & edgeManager,
FixedOneToManyRelation const & cellToEdges,
EmbeddedSurfaceBlockABC const & embeddedSurfaceBlock )
void EmbeddedSurfaceSubRegion::copyFromEmbeddedSurfaceBlock( localIndex const regionIndex,
localIndex const subRegionIndex,
NodeManager const & nodeManager,
EmbeddedSurfaceNodeManager & embSurfNodeManager,
EdgeManager const & edgeManager,
FixedOneToManyRelation const & cellToEdges,
EmbeddedSurfaceBlockABC const & embeddedSurfaceBlock )
{

arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const & nodesCoord = nodeManager.referencePosition();
Expand Down Expand Up @@ -419,9 +413,6 @@ bool EmbeddedSurfaceSubRegion::addAllEmbeddedSurfaces(
LvArray::tensorOps::copy< 3 >( m_tangentVector2[i], elemTangentialVectors2[i] );
this->calculateElementGeometricQuantities( elemNodeCoords.toViewConst(), i );
}

return true;

}

void EmbeddedSurfaceSubRegion::inheritGhostRank( array1d< array1d< arrayView1d< integer const > > > const & cellGhostRank )
Expand Down
12 changes: 12 additions & 0 deletions src/coreComponents/mesh/EmbeddedSurfaceSubRegion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ class EmbeddedSurfaceSubRegion : public SurfaceElementSubRegion

///@}

/**
* @brief Fill the EmbeddedSurfaceSubRegion by copying those of the source CellBlock
* @param embeddedSurfaceBlock the CellBlEmbeddedSurfaceBlock which properties (connectivity info) will be copied.
*/
void copyFromEmbeddedSurfaceBlock( localIndex const regionIndex,
localIndex const subRegionIndex,
NodeManager const & nodeManager,
EmbeddedSurfaceNodeManager & embSurfNodeManager,
EdgeManager const & edgeManager,
FixedOneToManyRelation const & cellToEdges,
EmbeddedSurfaceBlockABC const & embeddedSurfaceBlock );

private:

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ EmbeddedSurfaceGenerator::EmbeddedSurfaceGenerator( const string & name,

registerWrapper( viewKeyStruct::targetObjectsNameString(), &m_targetObjectsName ).
setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ).
setInputFlag( dataRepository::InputFlags::OPTIONAL ).
setInputFlag( dataRepository::InputFlags::REQUIRED ).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CusiniM why this would be required when vtk input is used?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not need the EmbeddedSurfaceGenerator at all when vtk is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right yes, that makes sense then

setDescription( "List of geometric objects that will be used to initialized the embedded surfaces/fractures." );

registerWrapper( viewKeyStruct::mpiCommOrderString(), &m_mpiCommOrder ).
Expand Down Expand Up @@ -130,121 +130,81 @@ void EmbeddedSurfaceGenerator::initializePostSubGroups()

NewObjectLists newObjects;

if( m_targetObjectsName.empty() ) // when targetObjects were not provided - try to import from vtk
// Loop over all the fracture planes
geometricObjManager.forGeometricObject< PlanarGeometricObject >( m_targetObjectsName, [&]( localIndex const,
PlanarGeometricObject & fracture )
{
MeshBody & meshBody = domain.getMeshBody( 0 );
CellBlockManagerABC const & cellBlockManager = meshBody.getCellBlockManager();
Group const & embSurfBlocks = cellBlockManager.getEmbeddedSurfaceBlocks();
string const & faceBlockName = embeddedSurfaceRegion.getFaceBlockName();
if( embSurfBlocks.hasGroup( faceBlockName ))
/* 1. Find out if an element is cut by the fracture or not.
* Loop over all the elements and for each one of them loop over the nodes and compute the
* dot product between the distance between the plane center and the node and the normal
* vector defining the plane. If two scalar products have different signs the plane cuts the
* cell. If a nodes gives a 0 dot product it has to be neglected or the method won't work.
*/
real64 const planeCenter[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( fracture.getCenter() );
real64 const normalVector[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( fracture.getNormal() );
// Initialize variables
globalIndex nodeIndex;
integer isPositive, isNegative;
real64 distVec[ 3 ];

elemManager.forElementSubRegionsComplete< CellElementSubRegion >(
[&]( localIndex const er, localIndex const esr, ElementRegionBase &, CellElementSubRegion & subRegion )
{
EmbeddedSurfaceBlockABC const & embSurf = embSurfBlocks.getGroup< EmbeddedSurfaceBlockABC >( faceBlockName );

elemManager.forElementSubRegionsComplete< CellElementSubRegion >(
[&]( localIndex const er, localIndex const esr, ElementRegionBase &, CellElementSubRegion & subRegion )
{
FixedOneToManyRelation const & cellToEdges = subRegion.edgeList();
arrayView2d< localIndex const, cells::NODE_MAP_USD > const cellToNodes = subRegion.nodeList();
FixedOneToManyRelation const & cellToEdges = subRegion.edgeList();

bool added = embeddedSurfaceSubRegion.addAllEmbeddedSurfaces( er,
esr,
nodeManager,
embSurfNodeManager,
edgeManager,
cellToEdges,
embSurf );
arrayView1d< integer const > const ghostRank = subRegion.ghostRank();

if( added )
{
// Add all the fracture information to the CellElementSubRegion
for( localIndex edfmIndex=0; edfmIndex < embSurf.numEmbeddedSurfElem(); ++edfmIndex )
{
localIndex cellIndex = embSurf.getEmbeddedSurfElemTo3dElem().toCellIndex[edfmIndex][0];
subRegion.addFracturedElement( cellIndex, edfmIndex );
newObjects.newElements[ {embeddedSurfaceRegion.getIndexInParent(), embeddedSurfaceSubRegion.getIndexInParent()} ].insert( edfmIndex );
}
}
} ); // end loop over subregions
}
}
else
{
// Loop over all the fracture planes
geometricObjManager.forGeometricObject< PlanarGeometricObject >( m_targetObjectsName, [&]( localIndex const,
PlanarGeometricObject & fracture )
{
/* 1. Find out if an element is cut by the fracture or not.
* Loop over all the elements and for each one of them loop over the nodes and compute the
* dot product between the distance between the plane center and the node and the normal
* vector defining the plane. If two scalar products have different signs the plane cuts the
* cell. If a nodes gives a 0 dot product it has to be neglected or the method won't work.
*/
real64 const planeCenter[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( fracture.getCenter() );
real64 const normalVector[3] = LVARRAY_TENSOROPS_INIT_LOCAL_3( fracture.getNormal() );
// Initialize variables
globalIndex nodeIndex;
integer isPositive, isNegative;
real64 distVec[ 3 ];

elemManager.forElementSubRegionsComplete< CellElementSubRegion >(
[&]( localIndex const er, localIndex const esr, ElementRegionBase &, CellElementSubRegion & subRegion )
forAll< serialPolicy >( subRegion.size(), [ &, ghostRank,
cellToNodes,
nodesCoord ] ( localIndex const cellIndex )
{
arrayView2d< localIndex const, cells::NODE_MAP_USD > const cellToNodes = subRegion.nodeList();
FixedOneToManyRelation const & cellToEdges = subRegion.edgeList();

arrayView1d< integer const > const ghostRank = subRegion.ghostRank();

forAll< serialPolicy >( subRegion.size(), [ &, ghostRank,
cellToNodes,
nodesCoord ] ( localIndex const cellIndex )
if( ghostRank[cellIndex] < 0 )
{
if( ghostRank[cellIndex] < 0 )
isPositive = 0;
isNegative = 0;
for( localIndex kn = 0; kn < subRegion.numNodesPerElement(); kn++ )
{
isPositive = 0;
isNegative = 0;
for( localIndex kn = 0; kn < subRegion.numNodesPerElement(); kn++ )
nodeIndex = cellToNodes[cellIndex][kn];
LvArray::tensorOps::copy< 3 >( distVec, nodesCoord[nodeIndex] );
LvArray::tensorOps::subtract< 3 >( distVec, planeCenter );
// check if the dot product is zero
if( LvArray::tensorOps::AiBi< 3 >( distVec, normalVector ) > 0 )
{
nodeIndex = cellToNodes[cellIndex][kn];
LvArray::tensorOps::copy< 3 >( distVec, nodesCoord[nodeIndex] );
LvArray::tensorOps::subtract< 3 >( distVec, planeCenter );
// check if the dot product is zero
if( LvArray::tensorOps::AiBi< 3 >( distVec, normalVector ) > 0 )
{
isPositive = 1;
}
else if( LvArray::tensorOps::AiBi< 3 >( distVec, normalVector ) < 0 )
{
isNegative = 1;
}
} // end loop over nodes

if( isPositive * isNegative == 1 )
isPositive = 1;
}
else if( LvArray::tensorOps::AiBi< 3 >( distVec, normalVector ) < 0 )
{
bool added = embeddedSurfaceSubRegion.addNewEmbeddedSurface( cellIndex,
er,
esr,
nodeManager,
embSurfNodeManager,
edgeManager,
cellToEdges,
&fracture );

if( added )
{
GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::SurfaceGenerator, "Element " << cellIndex << " is fractured" );

// Add the information to the CellElementSubRegion
subRegion.addFracturedElement( cellIndex, localNumberOfSurfaceElems );

newObjects.newElements[ {embeddedSurfaceRegion.getIndexInParent(), embeddedSurfaceSubRegion.getIndexInParent()} ].insert( localNumberOfSurfaceElems );

localNumberOfSurfaceElems++;
}
isNegative = 1;
}
} // end loop over nodes
if( isPositive * isNegative == 1 )
{
bool added = embeddedSurfaceSubRegion.addNewEmbeddedSurface( cellIndex,
er,
esr,
nodeManager,
embSurfNodeManager,
edgeManager,
cellToEdges,
&fracture );

if( added )
{
GEOS_LOG_LEVEL_INFO_RANK_0( logInfo::SurfaceGenerator, "Element " << cellIndex << " is fractured" );

// Add the information to the CellElementSubRegion
subRegion.addFracturedElement( cellIndex, localNumberOfSurfaceElems );

newObjects.newElements[ {embeddedSurfaceRegion.getIndexInParent(), embeddedSurfaceSubRegion.getIndexInParent()} ].insert( localNumberOfSurfaceElems );

localNumberOfSurfaceElems++;
}
}
} );// end loop over cells
} );// end loop over subregions
} );// end loop over planes
}
}
} );// end loop over cells
} );// end loop over subregions
} );// end loop over planes

// Launch kernel to compute connectivity index of each fractured element.
elemManager.forElementSubRegionsComplete< CellElementSubRegion >(
Expand Down
Loading