feat: support non-scalar valued field specifications #4034
Conversation
| /// The name of the function used to generate values for application. | ||
| string m_functionName; | ||
| /// Name(s) of the function used to generate values for application. | ||
| string_array m_functionName; |
There was a problem hiding this comment.
| string_array m_functionName; | |
| string_array m_functionNames; |
There was a problem hiding this comment.
| constexpr static char const * functionNamesString() { return "functionNames"; } |
There was a problem hiding this comment.
Same for scale -> scales.
There was a problem hiding this comment.
To avoid breaking users' input files, I kept it as "scale" (same for "functionName"). However, if the previously mentioned change/commit to accept unbracketed single values for 1D arrays is rejected, I will rename it to scales (unless breaking users' files in this case is acceptable?).
There was a problem hiding this comment.
Do both. Enforce scales = {}
There was a problem hiding this comment.
Could scales (plural) not be misleading here? Fields like permeability or globalCompFraction are already implicitly plural (one value per cell, per direction/component). Wouldn't scale (singular) better reflect that this is a single scaling vector applied along the second dimension?
| { | ||
| string const path = m_regionNames.empty() | ||
| ? m_objectPath | ||
| : "ElementRegions/{" + stringutilities::join( m_regionNames, ' ' ) + "}"; |
There was a problem hiding this comment.
This isn't quite what I expected. I expected a loop over the region names. Has this been tested with multiple regions?
There was a problem hiding this comment.
Yes, regionNames works with multiple regions (tested with isothermalLeakyWell_smoke_3d.xml). It relies on an objectPath capability that accepts multiple "nodes" at the same level (e.g., objectPath="ElementRegions/{ region1 region2 }").
However, after testing, I found that using objectPath="ElementRegions/{ region1 region2 }" in a XML does not work, whereas regionNames="{ region1, region2 }" does. This is likely due to a regex in the parsing phase that blocks it.
There was a problem hiding this comment.
However, after testing, I found that using
objectPath="ElementRegions/{ region1 region2 }"in a XML does not work, whereasregionNames="{ region1, region2 }"does. This is likely due to a regex in the parsing phase that blocks it.
This is not regex, it is fnmatch. This not a valid fnmatch pattern. Much to your users displeasure I think the valid fnmatch pattern is:
regionNames="ElementRegions/region[12]"
or full expansion:
regionNames="{ ElementRegions/region1, ElementRegions/region2 }"
annoyingly it would be hard (not possible) to get a fnmatch expansion to something like
ElementRegions/reservoir, ElementRegions/overburden
that would have to be:
{ ElementRegions/reservoir, ElementRegions/overburden }
alternatively if you take my suggestion that we just assume everything not FaceManager, EdgeManager, NodeManager is ElementRegion, then I think
objectPath="{ reservoir, overburden }"
would work as desired.
|
I've removed the |
…/nonScalarFieldSpecification
|
@kdrienCG can you look if you can add a check on the user input vector dimension in relation to the field tensorial dimensions? |
Potential solution was:
```cpp
#ifndef NDEBUG
GEOS_WARNING_IF( m_functionName.size() > 1,
"getFunctionName() used while m_functionName has multiple values. Consider using getFunctionNames()" );
#endif
```
It may not be worth bringing the whole Logger header for this check...
| * Accessor | ||
| * @return const m_scales | ||
| */ | ||
| arrayView1d< real64 const > getScales() const |
There was a problem hiding this comment.
Be consistent (plural) with scaleString() { return "scale"; }
| bool usesNonScalarValues() const | ||
| { return m_scale.size() > 1 || m_functionName.size() > 1; } |
There was a problem hiding this comment.
Seems quite complicated to maintain. To avoid having 4 ways branching ( scale scalar or not, functionNames scalar or not ), I suggest to, for scale and functionNames:
- control that if we have >1-dim vectors, it has the the same dimensions as the field (
numArrayComp()?) inpostProcessInput(); - still in
postProcessInput(), duplicate any 1-dim vector so it has the same dimensions as the field; - then we are able to remove this method, and any downstream branching.
rename "scale" to "scales" in the code only. rename "functionName" to "functionNames" in the code only.
…dSpecification' into feature/kdrienCG/nonScalarFieldSpecification
This PR generalizes field specifications to support non-scalar values, notably scales (and so function names).
The following interface is proposed:
Instead of:
This PR also add aregionNamesarray to make it easier to specify multiple regions.