Closed WilkAndy closed 4 years ago
Hey @loganharbour , in a NodalUserObject _subproblem.mesh().getMesh().n_local_nodes()
gives me the number of nodes that will be looped over in execute(). This is also the size of the std::vector<something>
that i'm trying to compute with my NodalUserObject (ie, the "something" exists at each node).
Presumably I will have to define a structure that maps _current_node->id()
that is available in execute() to the correct index in my std::vector<something>
What about coupledVars? Are they indexed by _current_node->id(), or something else. Viz, in execute(), should i be using var[_current_node->id()] or something else? EDIT: they have index [0].
I might like to do the loop over all local nodes in initialSetup
. If coupledVars are indexed by _current_node->id(), how do i know the index to use? EDIT: i'm pretty sure AuxVars values do not exist during the UserObject's initialSetup. This is a bit annoying - so far i'm sidestepping this issue by only allowing initially homogeneous distributions of reactants through the mesh (initial condition parameterised by Reals)
Hi again @loganharbour . Can you give me some design advice?
At every node, i need a ModelGeochemicalDatabase
. This holds the current basis species, the current equilibrium species, etc, that are relevant for that node. This is why i used a NodalUserObject in my "Reactor" classes. However, for reactive transport i see two possibilities, and i'm not really sure which is the best.
At every node, i also have a GeochemicalSystem
. This holds all the information about the current molalities (concentrations) of every species. In the NodalUserObject, i update this (given information about sources/sinks active at the node, and using a GeochemicalSolver
) at every time step. There may be AuxVariables that record some of these molalities - they just use the existing GeochemistyQuantityAux
.
At every node I demand that there are AuxVariables that record the molalities (and any other info i need). Perhaps @YaqiWang 's VectorAuxVariable thing. I only have one GeochemicalSystem
. In a loop over the nodes, i populate the single GeochemicalSystem
using the AuxVariables at the current node, solve the system, and repopulate the AuxVariables with the solution.
The advantage of (1) is that it's pretty simple coding, since this was the design all along. It also allows users to be quite precise with their "constraints", eg fixing pH at one node but not another, although i'm not sure whether anyone will actually do this. However, it might be more complicated with mesh adaptivity, since i'm not relying on MOOSE doing the right thing with AuxVariables. Also, it's more difficult to restart a crashed simulation. Also, it uses more memory than (2).
If I go for (2), perhaps i shouldn't use a UserObject? I will need to const_cast
the AuxVariables so i can directly write to them as soon as the GeochemicalSolver
finds the solution. Perhaps i should use an AuxKernel instead that modifies a bunch of AuxVariables at once? But i still need a ModelGeochemicalDatabase
at every node, which will be modified by the AuxKernel.
I tried to do (2), above. It didn't work well because i couldn't actually write to the AuxVariables using the UserObject, boohoo. Not sure why - the const_cast
was fine, but the AuxVariables didn't actually update.
(1) seems fine so far.
I just completed my first reactive transport sim with geochemistry
, @rpodgorney and @cpgr. Days of code-tidying to do, but the proof-of-concept is there - good way to end the week.
Well done Andy. Enjoy your weekend.
-- Robert Podgorney, PhD, PG Geothermal Program Manager, Idaho National Laboratory Modeling and Simulation Lead, Utah FORGE Program Thermal Systems Co-Lead, INL Integrated Energy Systems Initiative
Office: 208-526-1524
From: Andy Wilkins notifications@github.com Reply-To: idaholab/moose reply@reply.github.com Date: Friday, August 7, 2020 at 1:23 AM To: idaholab/moose moose@noreply.github.com Cc: Robert Podgorney Robert.Podgorney@inl.gov, Mention mention@noreply.github.com Subject: [EXTERNAL] Re: [idaholab/moose] Geochemistry: reactive transport (#15693)
I just completed my first reactive transport sim with geochemistry, @rpodgorneyhttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frpodgorney&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160662024&sdata=J8%2BoV6ldm0ED3PPrP%2BgQlUjnpFZonq1Rkac%2Bwk8RPvM%3D&reserved=0 and @cpgrhttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcpgr&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160662024&sdata=q5EdQ4pLlxq%2B%2BOslVG40R2dprkraxz6GZwm%2BfCNbz0w%3D&reserved=0. Days of code-tidying to do, but the proof-of-concept is there - good way to end the week.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fidaholab%2Fmoose%2Fissues%2F15693%23issuecomment-670371774&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160672018&sdata=LTwjcPQF%2B1CIVr2ECuBjFfeHHj9rXEMptiYBcANTdzU%3D&reserved=0, or unsubscribehttps://gcc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACWGDT5E6EEIGFR7YZBLBV3R7OTXLANCNFSM4PSY4POQ&data=02%7C01%7Crobert.podgorney%40inl.gov%7C9fcc0f4df09e4357baac08d83aa2cb62%7C4cf464b7869a42368da2a98566485554%7C0%7C0%7C637323818160672018&sdata=ZIlc9TK2rju6gECamDsmrMMkZfAoVqEJJ0YpIzAXlT8%3D&reserved=0.
Reason
Implement reactive-transport in the
geochemistry
module to allow these kinds of simulationsDesign
As i implement this functionality, i'll note the enhancements here since i'm currently not exactly sure what is required.
have_swapped_out_of_basis
andhave_swapped_into_basis
. EDIT: no pointer, just a DenseMatrixbasis_species_transported
andeqm_species_transported
andkin_species_transported
into ModelGeochemicalDatabase that indicate whether the species are involved in transport. Off the top of my head, iff (a species is a mineral or surface_sorption_related=true) thenspecies_transported = false
.ReactiveTransport
nodal UserObject.Impact
Reactive transport in the
geochemistry
module!