Skip to content

Commit

Permalink
Replace "host history" and "age statistics" node components
Browse files Browse the repository at this point in the history
Removes these two node components and replaces them with matched nodeOperator/nodePropertyExtractor classes. Includes test suite scripts to validate their behavior.
  • Loading branch information
abensonca committed Jul 27, 2021
1 parent 938850a commit 77f8f27
Show file tree
Hide file tree
Showing 18 changed files with 1,568 additions and 604 deletions.
2 changes: 0 additions & 2 deletions parameters/baryonicPhysicsConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,8 @@
<componentSatellite value="standard" />
<componentSpheroid value="standard" />
<componentSpin value="scalar" />
<componentAgeStatistics value="null" />
<componentDynamicsStatistics value="null" />
<componentFormationTime value="null" />
<componentHostHistory value="null" />
<componentIndices value="null" />
<componentInterOutput value="null" />
<componentMassFlowStatistics value="null" />
Expand Down
345 changes: 345 additions & 0 deletions source/nodes.operators.analyses.ages.F90

Large diffs are not rendered by default.

225 changes: 225 additions & 0 deletions source/nodes.operators.analyses.mass_host_maximum.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
!! Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
!! 2019, 2020, 2021
!! Andrew Benson <abenson@carnegiescience.edu>
!!
!! This file is part of Galacticus.
!!
!! Galacticus is free software: you can redistribute it and/or modify
!! it under the terms of the GNU General Public License as published by
!! the Free Software Foundation, either version 3 of the License, or
!! (at your option) any later version.
!!
!! Galacticus is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License
!! along with Galacticus. If not, see <http://www.gnu.org/licenses/>.

!!{
Implements a node operator class that tracks the maximum host halo mass which a node has occupied.
!!}

!![
<nodeOperator name="nodeOperatorMassHostMaximum">
<description>
A node operator class that tracks the maximum host halo mass which a node has occupied. Intended to be paired with the
\refClass{nodePropertyExtractorMassHostMaximum} class to extract those ages for output.
</description>
</nodeOperator>
!!]
type, extends(nodeOperatorClass) :: nodeOperatorMassHostMaximum
!!{
A node operator class that tracks the maximum host halo mass which a node has occupied.
!!}
private
integer :: massHostMaximumID
contains
!![
<methods>
<method name="update" description="Update the maximum host mass of this node."/>
</methods>
!!]
final :: massHostMaximumDestructor
procedure :: nodeInitialize => massHostMaximumNodeInitialize
procedure :: nodesMerge => massHostMaximumNodesMerge
procedure :: nodePromote => massHostMaximumNodePromote
procedure :: update => massHostMaximumUpdate
procedure :: differentialEvolutionPost => massHostMaximumDifferentialEvolutionPost
procedure :: autoHook => massHostMaximumAutoHook
end type nodeOperatorMassHostMaximum

interface nodeOperatorMassHostMaximum
!!{
Constructors for the {\normalfont \ttfamily massHostMaximum} node operator class.
!!}
module procedure massHostMaximumConstructorParameters
module procedure massHostMaximumConstructorInternal
end interface nodeOperatorMassHostMaximum

contains

function massHostMaximumConstructorParameters(parameters) result(self)
!!{
Constructor for the {\normalfont \ttfamily massHostMaximum} node operator class which takes a parameter set as input.
!!}
use :: Input_Parameters, only : inputParameters
implicit none
type(nodeOperatorMassHostMaximum) :: self
type(inputParameters ), intent(inout) :: parameters

self=nodeOperatorMassHostMaximum()
!![
<inputParametersValidate source="parameters"/>
!!]
return
end function massHostMaximumConstructorParameters

function massHostMaximumConstructorInternal() result(self)
!!{
Internal constructor for the {\normalfont \ttfamily massHostMaximum} node operator class.
!!}
use :: Galacticus_Nodes, only : defaultBasicComponent
implicit none
type(nodeOperatorMassHostMaximum) :: self

self%massHostMaximumID=defaultBasicComponent%addMetaProperty(var_str('massHostMaximum'),'basic:massHostMaximum',isEvolvable=.false.)
return
end function massHostMaximumConstructorInternal

subroutine massHostMaximumAutoHook(self)
!!{
Attach to various event hooks.
!!}
use :: Events_Hooks, only : openMPThreadBindingAtLevel, satelliteHostChangeEvent
implicit none
class(nodeOperatorMassHostMaximum), intent(inout) :: self

call satelliteHostChangeEvent%attach(self,massHostMaximumSatelliteHostChange,openMPThreadBindingAtLevel,label='massHostMaximum')
return
end subroutine massHostMaximumAutoHook

subroutine massHostMaximumDestructor(self)
!!{
Destructor for the {\normalfont \ttfamily massHostMaximum} node operator class.
!!}
use :: Events_Hooks, only : satelliteHostChangeEvent
implicit none
type(nodeOperatorMassHostMaximum), intent(inout) :: self

if (satelliteHostChangeEvent%isAttached(self,massHostMaximumSatelliteHostChange)) call satelliteHostChangeEvent%detach(self,massHostMaximumSatelliteHostChange)
return
end subroutine massHostMaximumDestructor

subroutine massHostMaximumUpdate(self,node,isMerging)
!!{
Update the maximum host mass of this node.
!!}
use :: Galacticus_Nodes, only : nodeComponentBasic
implicit none
class (nodeOperatorMassHostMaximum), intent(inout) :: self
type (treeNode ), intent(inout) :: node
logical , intent(in ) :: isMerging
class (nodeComponentBasic ), pointer :: basic , basicHost

if (.not.(node%isSatellite() .or. isMerging)) return
basic => node %basic()
basicHost => node%parent%basic()
call basic%metaPropertySet( &
& self%massHostMaximumID , &
& max( &
& basic %metaPropertyGet(self%massHostMaximumID), &
& basicHost%mass ( ) &
& ) &
& )
return
end subroutine massHostMaximumUpdate

subroutine massHostMaximumSatelliteHostChange(self,node)
!!{
Update the maximum host mass of this node in response to a change in host.
!!}
use :: Galacticus_Error, only : Galacticus_Error_Report
implicit none
class(* ), intent(inout) :: self
type (treeNode), intent(inout) :: node

select type (self)
class is (nodeOperatorMassHostMaximum)
call self%update(node,isMerging=.false.)
class default
call Galacticus_Error_Report('incorrect class'//{introspection:location})
end select
return
end subroutine massHostMaximumSatelliteHostChange

subroutine massHostMaximumNodeInitialize(self,node)
!!{
Initialize the maximum host mass of this node.
!!}
implicit none
class(nodeOperatorMassHostMaximum), intent(inout) :: self
type (treeNode ), intent(inout), target :: node

call self%update(node,isMerging=.false.)
return
end subroutine massHostMaximumNodeInitialize

subroutine massHostMaximumNodePromote(self,node)
!!{
Update the maximum host mass of this node as a result of node promotion.
!!}
use :: Galacticus_Nodes, only : nodeComponentBasic
implicit none
class(nodeOperatorMassHostMaximum), intent(inout) :: self
type (treeNode ), intent(inout) :: node
type (treeNode ), pointer :: nodeSatellite
class(nodeComponentBasic ), pointer :: basicSatellite, basicHost

call self%update(node,isMerging=.false.)
nodeSatellite => node%firstSatellite
do while (associated(nodeSatellite))
basicSatellite => nodeSatellite %basic()
basicHost => node %parent%basic()
call basicSatellite%metaPropertySet( &
& self%massHostMaximumID , &
& max( &
& basicSatellite%metaPropertyGet(self%massHostMaximumID), &
& basicHost %mass ( ) &
& ) &
& )
nodeSatellite => nodeSatellite%sibling
end do
return
end subroutine massHostMaximumNodePromote

subroutine massHostMaximumNodesMerge(self,node)
!!{
Update the maximum host mass of this node as a result of node merging.
!!}
implicit none
class(nodeOperatorMassHostMaximum), intent(inout) :: self
type (treeNode ), intent(inout) :: node

call self%update(node,isMerging=.true.)
return
end subroutine massHostMaximumNodesMerge

subroutine massHostMaximumDifferentialEvolutionPost(self,node)
!!{
Update the maximum host mass of this node, and of any satellite nodes.
!!}
implicit none
class(nodeOperatorMassHostMaximum), intent(inout) :: self
type (treeNode ), intent(inout) :: node
type (treeNode ), pointer :: nodeSatellite

call self%update(node,isMerging=.false.)
nodeSatellite => node%firstSatellite
do while (associated(nodeSatellite))
call self%update(nodeSatellite,isMerging=.false.)
nodeSatellite => nodeSatellite%sibling
end do
return
end subroutine massHostMaximumDifferentialEvolutionPost
Loading

0 comments on commit 77f8f27

Please sign in to comment.