Skip to content

Commit

Permalink
Metal exchange: Add the option to add a copied field of the metal fie…
Browse files Browse the repository at this point in the history
…ld BEFORE the exchange happens.
  • Loading branch information
Meissam L Bahlali authored and Meissam L Bahlali committed Aug 3, 2024
1 parent 839f043 commit a4c5725
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ICFERST/schemas/multiphase.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -3403,6 +3403,23 @@ scalar_field_choice =
generic_aliased_field
}
)
}|
## Copied Field of the Metal Field BEFORE the exchange steps happen (dissolution or precipitation).
## Name has to start with CopiedField_Metal (e.g., CopiedField_Metal_Cu).
element scalar_field {
attribute rank { "0" },
attribute name { xsd:string },
(
element diagnostic {
internal_algorithm,
attribute metal_field_name { string },
pressure_mesh_choice,
diagnostic_scalar_field
}|
element aliased {
generic_aliased_field
}
)
}
# Insert new diagnostic scalar fields here using the template:
# element scalar_field {
Expand Down
23 changes: 23 additions & 0 deletions ICFERST/schemas/multiphase.rng
Original file line number Diff line number Diff line change
Expand Up @@ -4178,6 +4178,29 @@ Adapting to this field is not recommended</a:documentation>
</element>
</choice>
</element>
<element name="scalar_field">
<a:documentation>Copied Field of the Metal Field BEFORE the exchange steps happen (dissolution or precipitation).
Name has to start with CopiedField_Metal (e.g., CopiedField_Metal_Cu).</a:documentation>
<attribute name="rank">
<value>0</value>
</attribute>
<attribute name="name">
<value>CopiedField_Metal</value>
</attribute>
<choice>
<element name="diagnostic">
<ref name="internal_algorithm"/>
<attribute name="metal_field_name">
<data type="string" datatypeLibrary=""/>
</attribute>
<ref name="pressure_mesh_choice"/>
<ref name="diagnostic_scalar_field"/>
</element>
<element name="aliased">
<ref name="generic_aliased_field"/>
</element>
</choice>
</element>
</choice>
<!--
Insert new diagnostic scalar fields here using the template:
Expand Down
3 changes: 3 additions & 0 deletions ICFERST/src/Multiphase_TimeLoop.F90
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ subroutine MultiFluids_SolveTimeLoop( state, &
end do
end if

! Option if we want to have a copied field of the metal field BEFORE the exchange (dissolution or precipitation) happens.
call copy_metal_field(state, packed_state, Mdims, ndgln)

!Metal dissolution happens here
if (have_option("/porous_media/Metal_dissolution"))call metal_dissolution(state, packed_state, Mdims, ndgln)
!Metal precipitation happens here
Expand Down
28 changes: 28 additions & 0 deletions ICFERST/src/multi_eos.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3302,4 +3302,32 @@ subroutine correction_mass_metal(state, packed_state, Mdims, ndgln, total_mass_b

end subroutine correction_mass_metal

!>@brief: subroutine to copy a Metal Field into a copied field BEFORE the exchange steps happen (dissolution or precipitation). This can be used to have access to a liquid or solid metal field before the exchange step has happened.
!>@param state Linked list containing all the fields defined in diamond and considered by Fluidity
!>@param packed_state Linked list containing all the fields used by IC-FERST, memory partially shared with state
!>@param Mdims Data type storing all the dimensions describing the mesh, fields, nodes, etc
!>@param ndgln Global to local variables
subroutine copy_metal_field(state, packed_state, Mdims, ndgln)
implicit none
type(state_type), dimension(:), intent (inout) :: state
type(state_type), intent (inout) :: packed_state
type(multi_dimensions), intent (in) :: Mdims
type(multi_ndgln), intent (in) :: ndgln
!Local variables
type(tensor_field), pointer :: metal_field
type(scalar_field), pointer :: metal_field_copied
integer :: stat, fields, k
character( len = option_path_len ) :: option_name
character( len = option_path_len ), save :: metal_field_name

call get_option("/material_phase[0]/scalar_field::CopiedField_Metal/diagnostic/metal_field_name",metal_field_name)

if ( have_option( '/material_phase[0]/scalar_field::CopiedField_Metal' ) ) then
metal_field=>extract_tensor_field(packed_state,"Packed"//trim(metal_field_name), stat)
metal_field_copied=>extract_scalar_field(state(1), "CopiedField_Metal", stat)
metal_field_copied%val(:) = metal_field%val(1,1,:)
end if

end subroutine copy_metal_field

end module multiphase_EOS

0 comments on commit a4c5725

Please sign in to comment.