Comments (5)
I will spend some time reading this more carefully, but an initial thought comes to mind. If we want to utilize multiple dispatch to help with this, it might be worth checking out: https://pypi.org/project/multimethod/
The only concerns I have are related to performance. I'm not sure how much heavy-duty compilation (python interpreter) needs to occur. We should carefully examine the performance impacts if we decide to go that route.
from arraycontext.
Just to make sure I understand what's meant to be broadcasted there. So in
flux_avg @ normal - 0.5*lam*(cv_tpair.ext - cv_tpair.int)
the normal
is an object array of DOFArray
, cv_tpair
is a (TracePair
of) ConservedVars
, where the mass and energy are DOFArray
and momentum is an object array, and flux_avg
is a ConservedVars
, where the mass and energy fluxes are object arrays of DOFArray
and the momentum flux is a 2D object array of DOFArray
. Is that right?
Then, we'd like to broadcast in the following cases
DOFArray
* object array (already in there), whereDOFArray
is the innerConservedVars
*DOFArray
(for variables), whereDOFArray
is the innerConservedVars
* object array (for fluxes), where the object array is the inner
Anything else?
Assuming most of that is true, I also prefer the bcast_container_types
idea. I don't really see how this can work in a more general setting with something like a priority between container subtrees (?), so having each container say what it can broadcast over and how to do it seems to be the sanest choice.
The inner
/outer
thing should just work for arithmetic operations that define an __rmul__
(and friends), right? So that leaves the comparisons and bit shifts, which already don't broadcast very well. Do we want to support those?
from arraycontext.
Also, Julia has quite a bit of machinery to customize broadcasting for various types
https://docs.julialang.org/en/v1/manual/interfaces/#man-interfaces-broadcasting
Can't say I've understood all the edge cases they're trying to cover with it, but one nice thing is that they have that .op
notation to explicitly request broadcasting.
from arraycontext.
Just to make sure I understand what's meant to be broadcasted there. So in (...)
If what I say here is confusing or is just reiterating what you've already said, then please ignore, but this is also for me, so if I am misguided here about any of these pieces somebody please set me straight!
We are using the ConservedVars object to store quantities for each conservation equation. Most of the time, it is just the fluid (or simulation) "state" - specifically for us, a scalar quantity (1 DOFArray) for each of mass
, energy
, but an ndim-vector (object array of DOFArrays) for momentum
, and an nspecies-vector for species_mass
. In all there are neqn = ndim + 2 + nspecies
conservation equations.
Sometimes, such as in this particular case, we also store ndim-vector quantities for each conservation equation, e.g. the flux vectors. We actually have both situations in the current expression we are considering. When we store vector quantities, the mass
component (of ConservedVars) is the "mass flux" an ndim-vector, and momentum
is then the ndim X ndim array with each row corresponding to the momentum component flux vector for each of the ndim components of momentum, and so on.
normal
is an ndim-vector and we need flux @ normal
(where flux is a ConservedVars storing ndim-vector quantities for each of the neqn conservation equations) to look at flux as like an neqn x ndim array.
lam
is a DOFArray and we need lam * [q]
, where [q]
is a ConservedVars object storing the simulation state, to have a "distributive" behavior wrt the components (i.e. conservation eqn) of the ConservedVars.
from arraycontext.
#15 contains a proposal along these lines. It'd be great if you all could take a look.
from arraycontext.
Related Issues (20)
- How should lazy actx.compile interact with memoization (on the output end)?
- Handling temperature initial guesses
- Deprecate `is_array_container` HOT 7
- CI failing in mypy HOT 1
- `actx.compile` for pytato should allow things that are not array containers HOT 2
- Dealing with constants in `freeze`
- `arraycontext.container.to_numpy` semantics HOT 8
- Issues with `zeros` et al functions of array contexts HOT 4
- Make it so array containers do not know their array context? HOT 8
- Make a way to ensure we always use the actx's allocator
- Regression: "Out of host memory" on Nvidia ICD HOT 4
- Exposing `np.select`? HOT 1
- Function outlining errors in mirgecom
- Add optional `allow_single_version` Boolean arg to `actx.compile` HOT 12
- Precision: What actually do `freeze`/`thaw` mean?
- `(zeros|ones|full)_like` and `axes`/`tags` HOT 2
- `test_array_context_np_workalike` may be flaky HOT 1
- Introduce a `-O0` mode to avoid full-blast code transformation for code that runs once
- Loopy a hard dependency? HOT 1
- eager arraycontext bug
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arraycontext.