-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix: Add source value array for fwi in wave solvers #3502
Open
acitrain
wants to merge
34
commits into
develop
Choose a base branch
from
fix/AddSourceValueTableForFWI
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+244
−81
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
be056b5
First attempt for fix
acitrain 5346a2d
Bugfix
acitrain 389cb18
Merge branch 'develop' into fix/AddSourceValueTableForFWI
sframba 31de5c1
fix issue calcul cycleNumber
labesse40 1ba92b0
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain ddfafef
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain 078e316
uncrustify
acitrain 0988baf
Remove unused variable
acitrain db08822
Add schema
acitrain a060ea9
Restore compilation option after push mistake
acitrain 5664509
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain 1386a95
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain ae06120
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain dad8001
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain e341a5e
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain ac6dc88
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain b02affd
Fix tolerance on test due to new source
acitrain 8c3f8ae
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain 1b2289e
uncrustify
acitrain 6cfce2e
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain ac5389d
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain 3fadd88
Fix bug when using cycleNumber
acitrain cd97257
uncrustify
acitrain 46a0f91
Remove unused variable
acitrain ff3f6a6
Merge branch 'develop' into fix/AddSourceValueTableForFWI
sframba 10e990b
Add schema files
acitrain a255893
Merge branch 'develop' into fix/AddSourceValueTableForFWI
acitrain a124254
Adress some comments
acitrain 45ac53f
Remove unused variable
acitrain d6486a4
uncrustify
acitrain ffaa60d
Update integrated hash
acitrain 5b4e015
Add test for table function when we fill sourceValue array
acitrain bd5bbbb
uncrustify
acitrain c2cf1d0
Update integrated tests hash
acitrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
baselines: | ||
bucket: geosx | ||
baseline: integratedTests/baseline_integratedTests-pr3395-9832-31f145e | ||
baseline: integratedTests/baseline_integratedTests-pr3502-10013-5b4e015 | ||
|
||
allow_fail: | ||
all: '' | ||
streak: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -146,6 +146,35 @@ void AcousticWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & baseM | |||||
receiverConstants.setValues< EXEC_POLICY >( -1 ); | ||||||
receiverIsLocal.zero(); | ||||||
|
||||||
arrayView1d< TableFunction::KernelWrapper const > const sourceWaveletTableWrappers = m_sourceWaveletTableWrappers.toViewConst(); | ||||||
bool useSourceWaveletTables = m_useSourceWaveletTables; | ||||||
|
||||||
//Correct size for sourceValue | ||||||
EventManager const & event = getGroupByPath< EventManager >( "/Problem/Events" ); | ||||||
real64 const & maxTime = event.getReference< real64 >( EventManager::viewKeyStruct::maxTimeString() ); | ||||||
real64 const & minTime = event.getReference< real64 >( EventManager::viewKeyStruct::minTimeString() ); | ||||||
real64 dt = 0; | ||||||
for( localIndex numSubEvent = 0; numSubEvent < event.numSubGroups(); ++numSubEvent ) | ||||||
{ | ||||||
EventBase const * subEvent = static_cast< EventBase const * >( event.getSubGroups()[numSubEvent] ); | ||||||
if( subEvent->getEventName() == "/Solvers/" + this->getName() ) | ||||||
{ | ||||||
dt = subEvent->getReference< real64 >( EventBase::viewKeyStruct::forceDtString() ); | ||||||
} | ||||||
} | ||||||
|
||||||
real64 dtCompute; | ||||||
|
||||||
localIndex nSubSteps = (int) ceil( dt/m_timeStep ); | ||||||
dtCompute = dt/nSubSteps; | ||||||
|
||||||
localIndex const nsamples = int( (maxTime - minTime) / dtCompute) + 1; | ||||||
|
||||||
localIndex const numSourcesGlobal = m_sourceCoordinates.size( 0 ); | ||||||
m_sourceValue.resize( nsamples, numSourcesGlobal ); | ||||||
|
||||||
arrayView2d< real32 > const sourceValue = m_sourceValue.toView(); | ||||||
|
||||||
mesh.getElemManager().forElementSubRegionsComplete< CellElementSubRegion >( regionNames, [&]( localIndex const, | ||||||
localIndex const er, | ||||||
localIndex const esr, | ||||||
|
@@ -192,7 +221,14 @@ void AcousticWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & baseM | |||||
receiverCoordinates, | ||||||
receiverIsLocal, | ||||||
receiverNodeIds, | ||||||
receiverConstants ); | ||||||
receiverConstants, | ||||||
sourceValue, | ||||||
dtCompute, | ||||||
m_timeSourceFrequency, | ||||||
m_timeSourceDelay, | ||||||
m_rickerOrder, | ||||||
sourceWaveletTableWrappers, | ||||||
useSourceWaveletTables ); | ||||||
} | ||||||
} ); | ||||||
elementSubRegion.faceList().freeOnDevice(); | ||||||
|
@@ -209,25 +245,24 @@ void AcousticWaveEquationSEM::precomputeSourceAndReceiverTerm( MeshLevel & baseM | |||||
nodesToElements.freeOnDevice(); | ||||||
} | ||||||
|
||||||
void AcousticWaveEquationSEM::addSourceToRightHandSide( real64 const & time_n, arrayView1d< real32 > const rhs ) | ||||||
void AcousticWaveEquationSEM::addSourceToRightHandSide( integer const & cycleNumber, arrayView1d< real32 > const rhs ) | ||||||
{ | ||||||
arrayView2d< localIndex const > const sourceNodeIds = m_sourceNodeIds.toViewConst(); | ||||||
arrayView2d< real64 const > const sourceConstants = m_sourceConstants.toViewConst(); | ||||||
arrayView1d< localIndex const > const sourceIsAccessible = m_sourceIsAccessible.toViewConst(); | ||||||
real32 const timeSourceFrequency = m_timeSourceFrequency; | ||||||
real32 const timeSourceDelay = m_timeSourceDelay; | ||||||
localIndex const rickerOrder = m_rickerOrder; | ||||||
bool useSourceWaveletTables = m_useSourceWaveletTables; | ||||||
arrayView1d< TableFunction::KernelWrapper const > const sourceWaveletTableWrappers = m_sourceWaveletTableWrappers.toViewConst(); | ||||||
arrayView2d< real32 const > const sourceValue = m_sourceValue.toViewConst(); | ||||||
|
||||||
GEOS_THROW_IF( cycleNumber > sourceValue.size( 0 ), | ||||||
getDataContext() << ": Too many steps compared to array size", | ||||||
std::runtime_error ); | ||||||
forAll< EXEC_POLICY >( sourceConstants.size( 0 ), [=] GEOS_HOST_DEVICE ( localIndex const isrc ) | ||||||
{ | ||||||
if( sourceIsAccessible[isrc] == 1 ) | ||||||
{ | ||||||
real64 const srcValue = | ||||||
useSourceWaveletTables ? sourceWaveletTableWrappers[ isrc ].compute( &time_n ) : WaveSolverUtils::evaluateRicker( time_n, timeSourceFrequency, timeSourceDelay, rickerOrder ); | ||||||
|
||||||
for( localIndex inode = 0; inode < sourceConstants.size( 1 ); ++inode ) | ||||||
{ | ||||||
real32 const localIncrement = sourceConstants[isrc][inode] * srcValue; | ||||||
real32 const localIncrement = sourceConstants[isrc][inode] * sourceValue[cycleNumber][isrc]; | ||||||
RAJA::atomicAdd< ATOMIC_POLICY >( &rhs[sourceNodeIds[isrc][inode]], localIncrement ); | ||||||
} | ||||||
} | ||||||
|
@@ -252,12 +287,10 @@ void AcousticWaveEquationSEM::initializePostInitialConditionsPreSubGroups() | |||||
|
||||||
|
||||||
|
||||||
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const & meshBodyName, | ||||||
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const &, | ||||||
MeshLevel & mesh, | ||||||
arrayView1d< string const > const & regionNames ) | ||||||
{ | ||||||
MeshLevel & baseMesh = domain.getMeshBodies().getGroup< MeshBody >( meshBodyName ).getBaseDiscretization(); | ||||||
precomputeSourceAndReceiverTerm( baseMesh, mesh, regionNames ); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
NodeManager & nodeManager = mesh.getNodeManager(); | ||||||
FaceManager & faceManager = mesh.getFaceManager(); | ||||||
|
@@ -338,6 +371,16 @@ void AcousticWaveEquationSEM::initializePostInitialConditionsPreSubGroups() | |||||
m_timeStep=dtOut; | ||||||
} | ||||||
|
||||||
forDiscretizationOnMeshTargets( domain.getMeshBodies(), [&] ( string const & meshBodyName, | ||||||
MeshLevel & mesh, | ||||||
arrayView1d< string const > const & regionNames ) | ||||||
{ | ||||||
GEOS_UNUSED_VAR( meshBodyName ); | ||||||
MeshLevel & baseMesh = domain.getMeshBodies().getGroup< MeshBody >( meshBodyName ).getBaseDiscretization(); | ||||||
precomputeSourceAndReceiverTerm( baseMesh, mesh, regionNames ); | ||||||
|
||||||
} ); | ||||||
|
||||||
|
||||||
WaveSolverUtils::initTrace( "seismoTraceReceiver", getName(), m_outputSeismoTrace, m_receiverConstants.size( 0 ), m_receiverIsLocal ); | ||||||
} | ||||||
|
@@ -875,7 +918,7 @@ real64 AcousticWaveEquationSEM::explicitStepForward( real64 const & time_n, | |||||
DomainPartition & domain, | ||||||
bool computeGradient ) | ||||||
{ | ||||||
real64 dtCompute = explicitStepInternal( time_n, dt, domain ); | ||||||
real64 dtCompute = explicitStepInternal( time_n, dt, cycleNumber, domain ); | ||||||
|
||||||
forDiscretizationOnMeshTargets( domain.getMeshBodies(), | ||||||
[&] ( string const &, | ||||||
|
@@ -946,7 +989,7 @@ real64 AcousticWaveEquationSEM::explicitStepBackward( real64 const & time_n, | |||||
DomainPartition & domain, | ||||||
bool computeGradient ) | ||||||
{ | ||||||
real64 dtCompute = explicitStepInternal( time_n, dt, domain ); | ||||||
real64 dtCompute = explicitStepInternal( time_n, dt, cycleNumber, domain ); | ||||||
forDiscretizationOnMeshTargets( domain.getMeshBodies(), | ||||||
[&] ( string const &, | ||||||
MeshLevel & mesh, | ||||||
|
@@ -1076,6 +1119,7 @@ void AcousticWaveEquationSEM::prepareNextTimestep( MeshLevel & mesh ) | |||||
|
||||||
void AcousticWaveEquationSEM::computeUnknowns( real64 const & time_n, | ||||||
real64 const & dt, | ||||||
integer const & cycleNumber, | ||||||
DomainPartition & domain, | ||||||
MeshLevel & mesh, | ||||||
arrayView1d< string const > const & regionNames ) | ||||||
|
@@ -1103,8 +1147,14 @@ void AcousticWaveEquationSEM::computeUnknowns( real64 const & time_n, | |||||
getDiscretizationName(), | ||||||
"", | ||||||
kernelFactory ); | ||||||
|
||||||
//Modification of cycleNember useful when minTime < 0 | ||||||
addSourceToRightHandSide( time_n, rhs ); | ||||||
EventManager const & event = getGroupByPath< EventManager >( "/Problem/Events" ); | ||||||
real64 const & minTime = event.getReference< real64 >( EventManager::viewKeyStruct::minTimeString() ); | ||||||
//localIndex const cycleNumber = time_n/dt; | ||||||
integer const cycleForSource = int(round( -minTime / dt + cycleNumber )); | ||||||
|
||||||
addSourceToRightHandSide( cycleForSource, rhs ); | ||||||
|
||||||
/// calculate your time integrators | ||||||
real64 const dt2 = pow( dt, 2 ); | ||||||
|
@@ -1228,6 +1278,7 @@ void AcousticWaveEquationSEM::synchronizeUnknowns( real64 const & time_n, | |||||
|
||||||
real64 AcousticWaveEquationSEM::explicitStepInternal( real64 const & time_n, | ||||||
real64 const & dt, | ||||||
integer const & cycleNumber, | ||||||
DomainPartition & domain ) | ||||||
{ | ||||||
GEOS_MARK_FUNCTION; | ||||||
|
@@ -1241,7 +1292,7 @@ real64 AcousticWaveEquationSEM::explicitStepInternal( real64 const & time_n, | |||||
{ | ||||||
localIndex nSubSteps = (int) ceil( dt/m_timeStep ); | ||||||
dtCompute = dt/nSubSteps; | ||||||
computeUnknowns( time_n, dtCompute, domain, mesh, regionNames ); | ||||||
computeUnknowns( time_n, dtCompute, cycleNumber, domain, mesh, regionNames ); | ||||||
synchronizeUnknowns( time_n, dtCompute, domain, mesh, regionNames ); | ||||||
} ); | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.