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

MueLu: How to pass primal/dual mapping to InterfaceMappingTransferFactory? #7164

Closed
mayrmt opened this issue Apr 14, 2020 · 12 comments
Closed

Comments

@mayrmt
Copy link
Member

mayrmt commented Apr 14, 2020

Question

@trilinos/muelu @kliegeois

I'm trying to understand how I can pass the information on the mapping of dual nodes to primal nodes for the InterfaceMappingTransferFactory introduced in PR #6931 for our application. I'm looking at the example in packages/muelu/test/meshtying/MeshTyingBlocked_SimpleSmoother.cpp.

As in the example, I want to read the preconditioner configuration from an xml-file. In contrast to the example, I want to create the preonditioner via MueLu::CreateXpetraPreconditioner().

The necessary information is set on the parameter list as shown here:

RCP<ParameterList> params = Teuchos::getParametersFromXmlFile(xmlFile);
RCP<ParameterList> paramsF, paramsI;
paramsF = sublist(params, "Factories");
paramsI = sublist(paramsF, "myInterfaceAggs2");
paramsI->set<RCP<std::map<LO, LO>>>("DualNodeID2PrimalNodeID - level 0", rcpFromRef(myLagr2Dof));

As far as I understand, this hard-codes the requires the sublist being named myInterfaceAggs2. However, the name of this list is defined in the xml-file as a user-specified string, so there's no guarantee that the user uses that particular name in every xml-file.

@kliegeois How can I pass the primal/dual node mapping to MueLu in a way, where I do not rely on particular sublist names in the MueLu xml-file?

@mayrmt mayrmt changed the title MueLu: How to pass primal/dual mapping to InterfaceAggregationFactory? MueLu: How to pass primal/dual mapping to InterfaceMappingTransferFactory? Apr 14, 2020
@kliegeois
Copy link
Contributor

Basically, what we need is the factory InterfaceAggregationFactory to have access to DualNodeID2PrimalNodeID - level 0.

In the example, as you said, I hard coded the InterfaceAggregationFactory to be named as myInterfaceAggs2.

I see two approaches not to hard code the name:

  • Give the name of the InterfaceAggregationFactory using a variable, possibly defined at the beginning of the xml file.
  • Scan the xml file, and keep the name of the (last) InterfaceAggregationFactory.

I think that the last approach would be better as it does not rely on the user to add other information (the name of the factory).
The only drawback would be that this prevents us from using 2 InterfaceAggregationFactory but I do not see any reason for doing that right now.

@mayrmt
Copy link
Member Author

mayrmt commented Apr 14, 2020

@kliegeois I like the second option better as well. There might be another: maybe this data also can be passed in via the "user data" sublist, similar to the fine-level nullspace and coordinate information.

@lucbv What do you think? Is this the intended use case of the "user data" sublist?

@lucbv
Copy link
Contributor

lucbv commented Apr 14, 2020

@mayrmt
Yes you can put that list on "user data" and recover it in your factory. I did not want to block @kliegeois previous PR because of that but the temptation was strong x)
Also if you really want a lot of flexibility you can pass a std::string to the interface factory (using the xml file) that tells you the name of the variable on "user data" to recover in case you have more than one interface.
I am not sure this last bit is the right design but that's at least possible and better than scanning the xml file entirely...

@kliegeois
Copy link
Contributor

@lucbv thanks for your input. That's definitely better.
Next time, feel free to block a PR if it can be improved!

@mayrmt
Copy link
Member Author

mayrmt commented Apr 14, 2020

@lucbv Thanks! I'll look into that. Maybe we can briefly talk about it later, so that you can point me to an example.

@tawiesn
Copy link
Contributor

tawiesn commented Apr 14, 2020

@mayrmt @kliegeois I like the idea with the "user data". This has been introduced for such things at some point, but i forgot about it.
However, there is still the implicit assumption that we only have one InterfaceMappingTransferFactory that consumes this information. But that's probably fine.

@mayrmt
Copy link
Member Author

mayrmt commented Apr 14, 2020

Well, then I’ll give the “user data” sublist a try.

@tawiesn For my application, one InterfaceAggregationFactory is sufficient for now. I guess that even multiple mortar interfaces can be handled, if all interfaces use the same mortar configuration.

@kliegeois Are there any concerns or objections from your side?

@kliegeois
Copy link
Contributor

@mayrmt It is definitely possible to have only one InterfaceAggregationFactory and have multiple mortar interfaces. I have tests in my application code which test those cases.

I have no concerns at all, thanks for looking into that!

@mayrmt
Copy link
Member Author

mayrmt commented Apr 16, 2020

@lucbv @tawiesn I'm putting the required data RCP<std::map<LO, LO>> myLagr2Dof on the "user data" parameter list as follows:

params->sublist("user data").set<RCP<std::map<LO, LO>>>("DualNodeID2PrimalNodeID", rcpFromRef(myLagr2Dof));

Now, I need to retrieve it during MueLu setup, but how?

To avoid errors such as

Throw test that evaluated to true: !IsKey(fac, ename)
"DualNodeID2PrimalNodeID" not found

I need to stick this data on the fine level. Is

  1. extracting non-serializable data
  2. adding non-serializable data to the hierarchy

the correct approach? Are there any others?

@lucbv
Copy link
Contributor

lucbv commented Apr 16, 2020

@mayrmt that seems reasonable to me, I am not sure that there many other options to handle that use case?

@mayrmt
Copy link
Member Author

mayrmt commented Apr 16, 2020

@lucbv I'll try that and let you know of my success. Or failure. 😉

mayrmt added a commit to mayrmt/Trilinos that referenced this issue Apr 17, 2020
For InterfaceAggregationFactory, the dual-to-primal node mapping needs
to be provided by the user on the "user data" sublist. Then, it is
treated as non-serializable data and added to the hierarchy during
CreateXpetraPreconditioner().

Adapted the test.

Part of trilinos#7164.
@mayrmt
Copy link
Member Author

mayrmt commented Apr 21, 2020

Has been addressed in #7194. Closing.

@mayrmt mayrmt closed this as completed Apr 21, 2020
kliegeois pushed a commit to kliegeois/Trilinos that referenced this issue May 29, 2020
For InterfaceAggregationFactory, the dual-to-primal node mapping needs
to be provided by the user on the "user data" sublist. Then, it is
treated as non-serializable data and added to the hierarchy during
CreateXpetraPreconditioner().

Adapted the test.

Part of trilinos#7164.
@jhux2 jhux2 added this to MueLu Aug 12, 2024
@jhux2 jhux2 moved this to Done in MueLu Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants