feat: add PermeabilitySpecification as an high-level FieldSpecification - #4019
Conversation
Implement methods to add factories to the manager to handle the creation of FieldSpecificationBase object via higher-level specifications (like PermeabilitySpecification)
|
Hi @kdrienCG |
Hi @rrsettgast , and thanks for the suggestion I propose doing that in a follow-up PR so we can keep this one focused on specialized components and easier to review. I've also put together a prototype to test the generalized approach, I can open a separate PR so we can agree on what its interface should be. |
Modify the specification parameter name in PermeabilitySpecificationFactory to match the parent class method definition (FieldSpecificationFactory)
…ure/kdrienCG/permeabilitySpecification
…dSpecification' into feature/kdrienCG/permeabilitySpecification
…ure/kdrienCG/permeabilitySpecification
…ist of types, only one REGISTER_* macro) + renaming generate->expand in case of more processing procedures
Co-authored-by: MelReyCG <122801580+MelReyCG@users.noreply.github.com>
Removes fieldName attribute as fieldKey is always "permeability" but introduces a new attribute "permeabilityModelName" for the constitutive model, as a complete fieldName for permeability is "constitutive_fieldkey"
| /** | ||
| * @brief Validate that a certain permeability model name exists in the domain | ||
| * @param domain The domain | ||
| * @param permeabilityModelName The name of the permeability model to validated | ||
| * @param permSpec Reference to the current object to print its DataContext | ||
| * @note Throws if the permeability model doesn't exists | ||
| */ | ||
| void expectValidPermeabilityModel( DomainPartition const & domain, | ||
| string const & modelName, | ||
| PermeabilitySpecification const & permSpec ) |
| // @copydoc FieldSpecificationABC::SetErrorMode | ||
| using SetErrorMode = FieldSpecificationABC::SetErrorMode; |
| registerWrapper( viewKeyStruct::permeabilityModelNameString(), &m_permeabilityModelName ). | ||
| setRTTypeName( rtTypes::CustomTypes::groupNameRef ). | ||
| setInputFlag( InputFlags::REQUIRED ). | ||
| setDescription( "Name of the constitutive permeability model." ); |
There was a problem hiding this comment.
📝Optional, ConstitutiveBase::makeFieldName won't be called if leaved empty.
| virtual string const & getFieldName() const override | ||
| { | ||
| static string const fieldName = fields::permeability::permeability::key(); | ||
| return fieldName; | ||
| } |
There was a problem hiding this comment.
| virtual string const & getFieldName() const override | |
| { | |
| static string const fieldName = fields::permeability::permeability::key(); | |
| return fieldName; | |
| } | |
| virtual string_view getFieldName() const override | |
| { return fields::permeability::permeability::key(); } |
There was a problem hiding this comment.
A lot of call sites expect a string const &, it will be a subject for another PR if you agree.
| void expectValidCellRegion( DomainPartition const & domain, | ||
| string const & fullRegionName, | ||
| PermeabilitySpecification const & permSpec ) | ||
| { |
There was a problem hiding this comment.
I think we can propose that as a standard method in the ABC + it has some sense to be a member function for the context retrieval.
| void expectValidCellRegion( DomainPartition const & domain, | |
| string const & fullRegionName, | |
| PermeabilitySpecification const & permSpec ) | |
| { | |
| template< typename ELEMENT_REGION_T > | |
| void FieldSpecificationABC::expectValidCellRegion( DomainPartition const & domain, | |
| string_view fullRegionName ) const | |
| { |
(Previously #4012)
(Discussion: #4092)
This PR proposes to add an easy way to add higher-level components that create FieldSpecifications without the boilerplate.
The goal of this component, along with future specialized field specifications (temperature, porosity, etc.), is to improve the experience for both the users and developers.
Compared to the standard
FieldSpecification, these components would:fieldName. It would also benefit from auto-generated documentation (see feat: add limits to input attributes #4063 that can even show value limits and enable automatic validation).postInputInitialization()for example).The
Groupsystem supports all of this: it gives developers a single place to document, validate, and optionally process user input. That is why this architecture is built onGroup.Hiding application data behind an interface is a common pattern that:
initialPressurefieldname, it is auto-filled by the pressure field; usepressurewithinitialCondition=1" or "do not touchdeltaPressureit is internal."The flexibility offered by
FieldSpecificationis not affected. The goal is not to remove it, but to provide a safer default alternative for common use cases, while still keepingFieldSpecificationavailable for advanced user, scenarios that require explicit data access and testing cases. Specialized components are built on top of it to ensure testing and support.More specialized field specifications will follow. For example, component fractions with constraints such as sum = 1.0, implemented by creating multiple
FieldSpecificationentries under the hood.As an example, to define the permeability you have to specify 3 differents FieldSpecifications.
One for the x-axis, a second for the y-axis, and a last one for the z-axis.
There is also some implementation details that could be hidden, like the
componentXML attribute for example.With this PR, their would be a
PermeabilitySpecificationcomponent that would create behind the scene those three FieldSpecifications to keep full compatibility with other parts that rely onFieldSpecificationBase. One could think of PermeabilitySpecification as a blueprint or recipe to create FieldSpecificationBase objects.Here is how it looks like for
PermeabilitySpecification:The following architecture is proposed: