CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Is there a way to do einstein summation in Openfoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 6, 2022, 10:06
Default Is there a way to do einstein summation in Openfoam
  #1
New Member
 
Join Date: Jul 2021
Posts: 1
Rep Power: 0
tbuchanan2 is on a distinguished road
Hi,

I was trying to figure out how to replicate numpy's einstein's summation (NumPy.einsum) in Openfoam and was wondering if any packages have been made.
tbuchanan2 is offline   Reply With Quote

Old   July 8, 2022, 04:25
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by tbuchanan2 View Post
Hi,

I was trying to figure out how to replicate numpy's einstein's summation (NumPy.einsum) in Openfoam and was wondering if any packages have been made.

After searching what numpy is actually doing there, the short (and longer) answer is "no, nothing like that in OpenFOAM".


To make that answer easier to accept, you need to be specific about what you are actually trying to achieve. Lets assume for the moment that this functionality would be really flexible and useful, you have the initial problem that everything in C++ (OpenFOAM) is strongly typed.
Consider an operation between two vectors: the inner product and outer product return different types. For numpy, these types can be "boxed" into the same object with the internals being something different. If you want this in OpenFOAM, you need a boxed representation as well and carry that through in various different places. If we extend that from a single vector/vector operation to a field (1D list) of vector/vector operations, the boxing would be at the top list level, not for each individual element.
So far, still seems doable (with a fair bit of coding). However, if we now want something actually useful, we should be talking about volVectorField etc. If these are to somehow be represented as boxed values, I have absolutely no idea what the boundary conditions should look like. Everything "calculated" or "zeroGradient"? Nothing else really makes sense. Processor-processor interfaces would also be highly interesting too.


If, on the other hand, you are interested in defining something that would be more "scripting", could think of extending or replacing the current "expressions" handling accordingly, but these are more of a domain-specific language rather than proper C++ OpenFOAM intrinsics.


Take a look at some of the expression handling in OpenFOAM. The lexing part is done with Ragel, the parser is written in Lemon, but expressed in more abstract rules with an m4 layer to allow reuse for different geometric types. Initially it may look a bit confusing, but IMO is actually a pretty solid combination. This is where you should be looking for squirreling in your additional einstein notation.
With the expressions handling, we have almost exactly the same situation of using boxed field representations.
olesen is offline   Reply With Quote

Reply

Tags
einstein summation, einsum


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 3 November 14, 2023 11:58
How to develop OpenFOAM with CMake and popular IDEs cosscholar OpenFOAM Programming & Development 0 March 16, 2022 15:17
OpenFOAM Training Jan-Jul 2017, Virtual, London, Houston, Berlin CFDFoundation OpenFOAM Announcements from Other Sources 0 January 4, 2017 06:15
OpenFOAM Foundation releases OpenFOAM 2.2.2 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 October 14, 2013 07:18
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07


All times are GMT -4. The time now is 22:48.