Implemented new kernel interface for flux - #1696
Conversation
| m_presAccessor = elemManager.constructArrayViewAccessor< real64, 1 >( keys::pressureString() ); | ||
| m_presAccessor.setName( solverName + "/accessors/" + keys::pressureString() ); | ||
| m_pres = m_presAccessor.toNestedViewConst(); |
There was a problem hiding this comment.
@klevzoff @CusiniM @rrsettgast I have a question about the elementViewAccessors in the new kernel interface.
My initial plan was to move the elementViewAccessors from the solver (ultimately removing CompositionalMultiphaseBase::resetViews) to the kernel, because I wanted to let the kernel choose which elementViewAccessors it needs. This is what is done in the current version of the PR, in which both the elementViewAccessors and the corresponding views are created in the constructor of the kernel interface (see highlighted code).
This plan works well for the CPU, but does not work on the GPU because the elementViewAccessors don't go to the GPU and make the code crash if they are stored in the kernel interface. Is there any way to keep this organization, but make it work on the GPU? Maybe the kernel factory can create the elementViewAccessors?
Alternatively, I can just leave the elementViewAccessors in the solver, and pass the views to the kernel factory, which will solve the problem on the GPU.
| * @tparam TRAITS the pack containing the types of the fields | ||
| */ | ||
| template< typename ... TRAITS > | ||
| class StencilAccessors |
There was a problem hiding this comment.
@francoishamon I moved this class into a separate file because ElementRegionManager is already pretty bloated, and this kind of storage class seems quite specific to the stencil-based physics solvers (maybe fluidFlow is too specific a place for it... we can move it later if we want). I also ended up combining StencilAccessors and StencilMaterialAccessors into one to avoid duplicating the code for accessing the data - it just has two distinct constructors, one for regular data and one for material.
| * @brief Define the interface for the assembly kernel in charge of flux terms | ||
| */ | ||
| template< integer NUM_COMP, integer NUM_DOF, typename STENCILWRAPPER > | ||
| class FaceBasedAssemblyKernel : public FaceBasedAssemblyKernelBase |
There was a problem hiding this comment.
Here I extracted a base class FaceBasedAssemblyKernelBase (above) which holds all the data independent of the template parameters, including all field accessors. The reason for that is that the constructor is quite large and involves a lot of template instantiations (first, the machinery of traits::type_list_index<> and then std::get<>) and I'd like to keep it in a separate translation unit (CompositionalMultiphaseFVMKernels.cpp) and also avoid it being recompiled for every combination of template parameters here.
| m_dPhaseCompFrac_dComp.toNestedViewConst(), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::phaseMobility{} ), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dPressure{} ), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity{} ), |
There was a problem hiding this comment.
This is the new way of extracting a specific accessor, hopefully pretty clean. We can also add using namespace extrinsicMeshData somewhere to make it even shorter.
There was a problem hiding this comment.
I only catching up with your modifications now, they look great! The getter for the accessor is now much better than in the previous version of the PR. Thanks!
In addition to using namespace, we could also change extrinsicMeshData to something shorter as discussed previously (in a separate PR). I still think it is a good idea because extrinsicMeshData is quite long to type.
There was a problem hiding this comment.
@francoishamon @klevzoff Would it be possible to just pass in the accessors and do the extraction inside the kernel? It seems that the kernels define the accessor types, so they could have knowledge of that type?
There was a problem hiding this comment.
Isn't it what the crateAndLaunch does? Maybe that has not been created for the hybridFVM Kernel?
There was a problem hiding this comment.
You're both right, this should be done in the kernel class, which has not been created for hybrid solver yet because @francoishamon is going to address it in a future PR
There was a problem hiding this comment.
Yes, this needs to be done in a separate PR that will also take care of the aquifer boundary condition kernel, and the CFLFlux kernel. I did not want to change too many things in this PR before making sure that everyone was ok with the new style.
|
@CusiniM @rrsettgast and anyone interested, if you have time to look at this PR, it is now ready for review. |
|
@rrsettgast @klevzoff @CusiniM I used the coarse version of the ECP stretch problem (2 target regions, 806k cells, 18 MPI ranks, 33 time steps, 234 nonlinear iterations). I got the following results (main kernels only): Total simulation time: 359 s Property updates: Assembly (including StencilAccessorCreation): Solve (including CopyJacobian): |
rrsettgast
left a comment
There was a problem hiding this comment.
This looks great. Just a couple of questions.
| m_dPhaseCompFrac_dComp.toNestedViewConst(), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::phaseMobility{} ), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dPressure{} ), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity{} ), |
There was a problem hiding this comment.
@francoishamon @klevzoff Would it be possible to just pass in the accessors and do the extraction inside the kernel? It seems that the kernels define the accessor types, so they could have knowledge of that type?
| */ | ||
| GEOSX_HOST_DEVICE | ||
| integer getElemGhostRank( localIndex const ei ) const | ||
| integer elemGhostRank( localIndex const ei ) const |
There was a problem hiding this comment.
can we just get rid of this accessor and use the member?
There was a problem hiding this comment.
Yes, we can get rid of that. I am taking note of this and will remove in the next PR.
| * @param[in] regionNames the name of the solver target regions | ||
| * @param[in] materialNames the name of the solver material names | ||
| */ | ||
| StencilAccessors( ElementRegionManager const & elemManager, |
There was a problem hiding this comment.
We are gonna have to change this interface after the multiple meshBody PR goes in (or in that exact PR) coz both materialNames and regionNames won't be available any more. At least not the way they are now.
CusiniM
left a comment
There was a problem hiding this comment.
This looks good to me. It will be painful to merge with the other PR and we will need to change a few things but we will deal with it.
| m_dPhaseCompFrac_dComp.toNestedViewConst(), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::phaseMobility{} ), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dPressure{} ), | ||
| compFlowAccessors.get( extrinsicMeshData::flow::dPhaseMobility_dGlobalCompDensity{} ), |
There was a problem hiding this comment.
Isn't it what the crateAndLaunch does? Maybe that has not been created for the hybridFVM Kernel?
|
Sorry, I am doing one last commit to fix a compilation warning on Lassen. I checked the integrated tests on Quartz and Lassen, no diffs, except the usual ones due to integer types on Lassen. We can merge the PR when the CI tests are done. Thanks @klevzoff for all the help on this PR! |
This PR implements the new kernel interface for the flux in
CompositionalMultiphaseFVM. For now, everything is isothermal, although I left a commented out placeholder to instantiate the kernel class in the thermal case.