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

DofManager #271

Merged
merged 52 commits into from
Apr 4, 2019
Merged

DofManager #271

merged 52 commits into from
Apr 4, 2019

Conversation

joshua-white
Copy link
Contributor

Create a degree-of-freedom manager to provide convenient interface between physics solvers and linear algebra objects. This first cut at the implementation will focus on providing global indexing and sparsity pattern capabilities.

Copy link
Contributor

@andrea-franceschini andrea-franceschini left a comment

Choose a reason for hiding this comment

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

On monday Antoine (if available) and I will start the design phase.

@joshua-white
Copy link
Contributor Author

Okay, I will start working on the basic implementation right now, since there is some obvious infrastructure to set up. Let's then plan to meet Tuesday at Stanford to discuss the desired design and we can go from there.


blt_add_test( NAME ${test_name}
COMMAND ${test_name}
NUM_MPI_TASKS 2 )
COMMAND ${test_name} -i ${CMAKE_CURRENT_LIST_DIR}/testDofManager.xml -x ${nranks}
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to be ignored by the other tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, all tests read testDofManager.xml but then ignore it if they don't need it. I'll make them separate so they can have different commands.

As a separate note, I had to copy quite a bit of GEOSX main() code to a test main() in order to set up a problem manager / mesh that could then be used to test the DofManager. It looks like Sergey did a similar thing for the compositional solver. Is it worth trying to create some reusable code somewhere for the test suite that would set up a relatively complete GEOSX "environment" for subsequent testing (i.e. initialize MPI comms, problem manager, input parsing). Does that make sense? I imagine people will be doing this all over the test suite. At some point the "unit" tests start to look pretty integrated.

Copy link
Member

Choose a reason for hiding this comment

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

yes it does. However, the lines between unit test and integrated test get a little blurry. Perhaps put a dummy data structure function in ProblemManager.

Copy link
Member

@rrsettgast rrsettgast left a comment

Choose a reason for hiding this comment

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

just questions

@joshua-white
Copy link
Contributor Author

Hi All, I uploaded a quick prototype for the DofManager. Please see DofManager.hpp. Think of this as a general proposal for the interface rather than working code.

* DoFManager and the LAI implementation, without relying on a specific
* LAI choice
*/
struct SparsityPattern
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to use a similar structure for FVManager to store FV stencils (but make it a weighted graph, and also a full-fledged class, with interfaces for incremental construction, etc.). Do we want to take advantage of the functionality overlap and define a generic templated CSRGraph class? Or would you rather keep them separate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've gone back and forth a few times about the best way to handle graphs. We have many options:

  1. The lightweight option here, which doesn't provide any functionality at all. Its just a simple way to pass sparsity pattern information back and forth between different code components. I started here to get the code up and running asap. It's not a good endpoint.
  2. Writing our own CRSGraph as you suggested, with more complete functionality.
  3. Wrapping a graph implementation from somewhere else (Trilinos, Hypre, PETSc, ParMetis).

For your case, a weighted graph is basically a CRSMatrix, right? Can we use one of our wrapped ParallelMatrix objects for this purpose?

Copy link
Member

Choose a reason for hiding this comment

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

I think the sparsity pattern has merit on its own. The stencil (FVM) and stiffness matrix (FEM) are essentially copies of the sparsity pattern, but with double values rather than indices. Is this the right way to think about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Randy. Once the sparsity pattern is done, to create the stencil and stiffness matrix is just a matter of assembling double values in the right positions.

Copy link
Member

Choose a reason for hiding this comment

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

we can create a

template< typename T, int NDIM >
class csrArray;

as part of the array classes to handle all csrArray-like needs.

Copy link
Contributor

@AntoineMazuyer AntoineMazuyer left a comment

Choose a reason for hiding this comment

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

I like the way you propose to add Dofs.

* Example 2 = add("pressure",CELL,FACE,1) for a scalar TPFA-type approximation
* Example 3 = add("pressure",CELL,NODE,1) for a scalar MPFA-type approximation
* Example 4 = add("mass",CELL,NONE,1) for a diagonal-only sparsity pattern (no connections)
*
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have additional "Control volumes" for faults and fractures, what is the best way to proceed ? Because we will have, if the fracture is represented as a surface :

  • Faces connected to cells through.... faces I guess ?
  • Faces connected to faces through edges.

(There is also a similar issue with the wells.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other complicated cases to consider are: (1) when physics is only assigned to certain element regions, but not others, and (2) a multilevel extension of the DofManager. I thought I would tackle the obvious cases first before struggling through the harder ones. The functionality and basic operations will always be the same (assigning dofs, using connectivity lists to compute sparsity patterns, etc) but the input specification could get more complicated.

Copy link
Member

Choose a reason for hiding this comment

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

I think that this approach is fine for the DOF that correlate to some mesh pattern. For some of the non-mesh related connectivity, I think that the best/most flexible approach will have to be a manual input.

for 1) there could be some indicator of element region in the interface. Since the regions only apply to elements, the faces and nodes won't be dependent on the region....but if we ever decided to add the ability to have separate mesh bodies and treat each one as a separate region, then the fields will be useful. Perhaps instead of NODE, FACE, CELL there should be a path that is extracted from the input file. For instance if there is a mesh body called BODY0, and a region called REGION0, the input would be BODY0/NODE, and BODY0/FACE, and BODY0/REGION0/CELL
for 2) I think that there would be some benefit treating each level independently from the DOF manager perspective, but have a restriction and prolongation operator generated by the solver.

/**
* Return global number of dofs across all processors. If field argument is "all", return monolithic size.
*/
globalIndex numGlobalDofs( string const & field = "all" ) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Concerning the MPI partitioning, we're probably going to deal with "Ghost" dofs ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, though the GEOSX ghosted mesh and the linear algebra libraries can help us out a lot here.

Copy link
Member

Choose a reason for hiding this comment

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

It will be just like the current implementation which does a synchronization of globalDOF numbers for each object that has a DOF.

@rrsettgast
Copy link
Member

Andrea. Do you need some assistance with a bug? It looks like you have a lot of commits trying to fix an apple error. Let me know if I can help.

@andrea-franceschini
Copy link
Contributor

Yes!!!
I did not want to ask this week because of the French travel, but yes, I need help. I added a new feature to the DofManager, i.e. the possibility to handle a user-provided pattern. This feature seems work well, but the small driver that creates this sparsity pattern has some problems. On every architecture it runs without issues, except for Apple xcode10, where is says that there it some problem with the final call to CellElementSubRegion destructor.
The problem is that I am working on a Ubuntu machine and here both gcc and clang works properly. I am not able to reproduce the error locally.

@rrsettgast
Copy link
Member

@AF1990 OK. Don't waste anymore time on it. I'll take care of it....if it is something that doesn't require major changes.

@andrea-franceschini
Copy link
Contributor

Ok, thanks! No, it should not require major changes. It is a very localized problem.

@rrsettgast
Copy link
Member

@AF1990 this is actually a really hard thing to diagnose. Valgrind gives some non-helpful information about a stack error. I don't know if you are using a ton of stack memory?

Are you using some interdependent singletons?

Playing around with all these commits, the only commit that doesn't fail is
430ef90. Commit 758bd69 fails. Do you think it would be possible to make a branch on that commit and merge that? Then we can carefully add to it.

@andrea-franceschini
Copy link
Contributor

I know ... I already tried Valgring without success. Moreover, I don't use any stack memory.
And, as far as I know, I don't use any interdependent singleton.
To understand which is the error, I started commenting the code. The single commit passing the tests is just the code without the routine creating the pattern.
My idea is the to have a driver calling a routine to create a pattern and use this "external" pattern within the DofManager. The new DofManager doesn't seems to have problem. The issue is in the routine creating the pattern. In that commit, the routine was commented out.
I don't think it a good idea to merge the new DofManager into the develop brach without the routine to test it ...

@andrea-franceschini
Copy link
Contributor

Finally I was able to understand the Apple XCode10 error!!!
It is really amazing ... the issue was the order of elements in CMakeLists.txt.
After 10 days of searching ... google/benchmark#52!!!

@andrea-franceschini
Copy link
Contributor

Can it be merged now???

@joshua-white
Copy link
Contributor Author

Well, that's frustrating. But yes, let's merge.

@andrea-franceschini
Copy link
Contributor

Well, that's frustrating. But yes, let's merge.

Yes ... quite frustrating ...

@klevzoff
Copy link
Contributor

klevzoff commented Apr 2, 2019

Note that in the referenced issue, the solution was to make some static variables non-static, rather than changing the build order. While I'm happy this issue is fixed for now, it looks like we may have a hidden problem with static init/deinit order dependency? Are we sure it won't blow up elsewhere? Or is it purely an Apple bug that needs to be worked around?

@andrea-franceschini
Copy link
Contributor

@klevzoff, you are right! But I don't use any static variable, except for the MAX_NUM_FIELD definition.
Anyway, let me have a more closer look at this issue. I cited the referenced issue just because with their idea I was able to overcome the problem.

@klevzoff
Copy link
Contributor

klevzoff commented Apr 2, 2019

@AF1990 I don't think the problem, if any, is with your code. I think it might just have surfaced in this PR due to a particular test and build sequence that appeared here.

I actually think this is a bug with gtest framework, the same as the one you referenced (I suspect, gtest and benchmark share some code base). It would be great to see if they fixed it also in gtest and update our bundled version if so. But this is not a task for this PR, which is in great shape. Don't waste any time on this.

@andrea-franceschini
Copy link
Contributor

👍

@rrsettgast
Copy link
Member

So what is the static variable/object that is causing the problem?

@andrea-franceschini
Copy link
Contributor

I really don't know. I checked and in the DofManager there are no static variables (except for a static member in the main class). As @klevzoff pointed out, probably, this a gtest or benchmark problem, because I note even if everything is commented out.

@joshua-white
Copy link
Contributor Author

@rrsettgast I propose we merge this and just make a separate issue. I don't want to hold up progress on the DoFManager, and this issue seems to be a bit separate from that topic. There is something we don't understand about static variable treatment in Apple/Clang10. Changing the order in the linking phase having an impact is odd, but this is probably reflecting a problem elsewhere, not the DofManager.

@rrsettgast
Copy link
Member

@joshua-white totally agree. do the honors....

@joshua-white joshua-white merged commit fba9a9d into develop Apr 4, 2019
@andrea-franceschini andrea-franceschini deleted the feature/white/dofManager branch July 8, 2019 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants