-
Notifications
You must be signed in to change notification settings - Fork 106
feat: support non-scalar valued field specifications #4034
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
base: develop
Are you sure you want to change the base?
Changes from 34 commits
c8adaac
67da13f
e133dd2
7c18352
2dc1751
d5fbc7f
e7af0f5
663a168
7e4f6a5
839d653
b0ae8d2
e073b5f
156ffc7
bfb53d5
d74a3d1
f684f70
28dbcff
0ecdd93
76d2297
27a5eb8
d766df1
0013c0a
4c708e0
b0b3df9
7267a4d
aef69ab
bd0fbab
9664351
00d6eaf
04d0563
927eec4
a3cf042
2f0f3da
9fe1d2a
8e4eaed
6012577
05597b5
94cbfde
42e7581
c3c4882
3027e18
11ed988
6f7047f
cece6cb
ec3d94e
464a35e
7d5407c
bc2d384
bfd9d98
3036722
e0e6769
06cd526
c31f8e3
29dc99d
ef4dd72
22714e3
3231189
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |
|
|
||
| #include "FieldSpecificationBase.hpp" | ||
|
|
||
| #include "common/format/StringUtilities.hpp" | ||
| #include "common/logger/Logger.hpp" | ||
| #include "fieldSpecification/FieldSpecificationManager.hpp" | ||
|
|
||
| namespace geos | ||
|
|
@@ -39,6 +41,11 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par | |
| setInputFlag( InputFlags::OPTIONAL ). | ||
| setDescription( "Path to the target field" ); | ||
|
|
||
| registerWrapper( viewKeyStruct::regionNamesString(), &m_regionNames ). | ||
| setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). | ||
| setInputFlag( InputFlags::OPTIONAL ). | ||
| setDescription( "Names of the regions where the field specification is applied." ); | ||
|
|
||
| registerWrapper( viewKeyStruct::fieldNameString(), &m_fieldName ). | ||
| setRTTypeName( rtTypes::CustomTypes::groupNameRef ). | ||
| setInputFlag( InputFlags::OPTIONAL ). | ||
|
|
@@ -57,9 +64,9 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par | |
| setDescription( "Direction to apply boundary condition to." ); | ||
|
|
||
| registerWrapper( viewKeyStruct::functionNameString(), &m_functionName ). | ||
| setRTTypeName( rtTypes::CustomTypes::groupNameRef ). | ||
| setRTTypeName( rtTypes::CustomTypes::groupNameRefArray ). | ||
| setInputFlag( InputFlags::OPTIONAL ). | ||
| setDescription( "Name of function that specifies variation of the boundary condition." ); | ||
| setDescription( "Name(s) of function(s) that specifies variation of the boundary condition." ); | ||
|
|
||
| registerWrapper( viewKeyStruct::bcApplicationTableNameString(), &m_bcApplicationFunctionName ). | ||
| setRTTypeName( rtTypes::CustomTypes::groupNameRef ). | ||
|
|
@@ -69,7 +76,8 @@ FieldSpecificationBase::FieldSpecificationBase( string const & name, Group * par | |
| registerWrapper( viewKeyStruct::scaleString(), &m_scale ). | ||
| setApplyDefaultValue( 0.0 ). | ||
| setInputFlag( InputFlags::OPTIONAL ). | ||
| setDescription( "Apply a scaling factor for the value of the boundary condition." ); | ||
| setSizedFromParent( 0 ). | ||
| setDescription( "Apply scaling factor(s) for the value(s) of the boundary condition." ); | ||
|
|
||
| registerWrapper( viewKeyStruct::initialConditionString(), &m_initialCondition ). | ||
| setApplyDefaultValue( 0 ). | ||
|
|
@@ -110,22 +118,58 @@ FieldSpecificationBase::getCatalog() | |
| } | ||
|
|
||
|
|
||
| void FieldSpecificationBase::postInputInitialization() | ||
| { | ||
| GEOS_THROW_IF( !m_functionName.empty() && | ||
| m_functionName.size() != 1 && | ||
| m_functionName.size() != static_cast< string_array::size_type >( m_scale.size() ), | ||
| GEOS_FMT ( "Size mismatch: '{}' has {} entries but '{}' has {}. " | ||
| "'{}' either must be empty, have a single entry, or be sized exactly like '{}'", | ||
| viewKeyStruct::functionNameString(), m_functionName.size(), | ||
| viewKeyStruct::scaleString(), m_scale.size(), | ||
| viewKeyStruct::functionNameString(), viewKeyStruct::scaleString() ), | ||
| InputError, | ||
| getDataContext() ); | ||
|
|
||
| if( usesNonScalarValues() ) | ||
| { | ||
| GEOS_THROW_IF( m_component != -1, | ||
| GEOS_FMT ( "'{}' must not be set when '{}' has more than one value.", | ||
| viewKeyStruct::componentString(), | ||
| viewKeyStruct::scaleString() ), | ||
| InputError, | ||
| getDataContext() ); | ||
| } | ||
|
|
||
| if( !m_regionNames.empty() ) | ||
| { | ||
| GEOS_THROW_IF( !m_objectPath.empty(), | ||
| GEOS_FMT ( "'{}' must not be set when '{}' is set.", | ||
| viewKeyStruct::objectPathString(), | ||
| viewKeyStruct::regionNamesString() ), | ||
| InputError, | ||
| getDataContext() ); | ||
| } | ||
| } | ||
|
|
||
| void FieldSpecificationBase::setMeshObjectPath( Group const & meshBodies ) | ||
| { | ||
| string const path = m_regionNames.empty() | ||
| ? m_objectPath | ||
| : "ElementRegions/{" + stringutilities::join( m_regionNames, ' ' ) + "}"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't quite what I expected. I expected a loop over the region names. Has this been tested with multiple regions?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, However, after testing, I found that using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is not regex, it is fnmatch. This not a valid
or full expansion: annoyingly it would be hard (not possible) to get a fnmatch expansion to something like
that would have to be:
alternatively if you take my suggestion that we just assume everything not
would work as desired. |
||
| try | ||
| { | ||
| m_meshObjectPaths = std::make_unique< MeshObjectPath >( m_objectPath, meshBodies ); | ||
| m_meshObjectPaths = std::make_unique< MeshObjectPath >( path, meshBodies ); | ||
| } | ||
| catch( std::exception const & e ) | ||
| { | ||
| ErrorLogger::global().modifyCurrentExceptionMessage() | ||
| .addToMsg( getWrapperDataContext( viewKeyStruct::objectPathString() ).toString() + | ||
| " is a wrong objectPath: " + m_objectPath + "\n" ) | ||
| " is a wrong objectPath: " + path + "\n" ) | ||
| .addContextInfo( getWrapperDataContext( viewKeyStruct::objectPathString() ).getContextInfo() | ||
| .setPriority( 2 ) ); | ||
| throw InputError( e, getWrapperDataContext( viewKeyStruct::objectPathString() ).toString() + | ||
| " is a wrong objectPath: " + m_objectPath + "\n" ); | ||
| " is a wrong objectPath: " + path + "\n" ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.