Skip to content

Commit

Permalink
Merge pull request #651 from galacticusorg/featFilterLabelPostEvolve
Browse files Browse the repository at this point in the history
Allow filter-based labelling on post-evolution
  • Loading branch information
abensonca authored Jul 26, 2024
2 parents da79ef8 + d022147 commit d08a189
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 17 deletions.
58 changes: 44 additions & 14 deletions source/nodes.operators.metadata.label.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@
private
type (varying_string ) :: label
integer :: labelID
logical :: onInitialize , onPostEvolution
class (galacticFilterClass), pointer :: galacticFilter_ => null()
contains
final :: labelDestructor
procedure :: nodeTreeInitialize => labelTreeInitialize
final :: labelDestructor
procedure :: nodeTreeInitialize => labelTreeInitialize
procedure :: differentialEvolutionPost => labelDifferentialEvolutionPost
end type nodeOperatorLabel

interface nodeOperatorLabel
Expand All @@ -57,38 +59,52 @@ function labelConstructorParameters(parameters) result(self)
!!}
use :: Input_Parameters, only : inputParameters
implicit none
type (nodeOperatorLabel ) :: self
type (inputParameters ), intent(inout) :: parameters
class(galacticFilterClass), pointer :: galacticFilter_
type (varying_string ) :: label
type (nodeOperatorLabel ) :: self
type (inputParameters ), intent(inout) :: parameters
class (galacticFilterClass), pointer :: galacticFilter_
type (varying_string ) :: label
logical :: onInitialize , onPostEvolution

!![
<inputParameter>
<name>label</name>
<source>parameters</source>
<description>The label to apply.</description>
</inputParameter>
<inputParameter>
<name>onInitialize</name>
<source>parameters</source>
<defaultValue>.true.</defaultValue>
<description>If true set the label on tree initialization.</description>
</inputParameter>
<inputParameter>
<name>onPostEvolution</name>
<source>parameters</source>
<defaultValue>.false.</defaultValue>
<description>If true set the label after each differential evolution.</description>
</inputParameter>
<objectBuilder class="galacticFilter" name="galacticFilter_" source="parameters"/>
!!]
self=nodeOperatorLabel(label,galacticFilter_)
self=nodeOperatorLabel(label,onInitialize,onPostEvolution,galacticFilter_)
!![
<inputParametersValidate source="parameters"/>
<objectDestructor name="galacticFilter_"/>
!!]
return
end function labelConstructorParameters

function labelConstructorInternal(label,galacticFilter_) result(self)
function labelConstructorInternal(label,onInitialize,onPostEvolution,galacticFilter_) result(self)
!!{
Constructor for the {\normalfont \ttfamily label} node operator class which takes a parameter set as input.
!!}
use :: Nodes_Labels, only : nodeLabelRegister
implicit none
type (nodeOperatorLabel ) :: self
type (varying_string ), intent(inout) :: label
class(galacticFilterClass), intent(in ), target :: galacticFilter_
type (nodeOperatorLabel ) :: self
type (varying_string ), intent(inout) :: label
logical , intent(in ) :: onInitialize , onPostEvolution
class (galacticFilterClass), intent(in ), target :: galacticFilter_
!![
<constructorAssign variables="label, *galacticFilter_"/>
<constructorAssign variables="label, onInitialize, onPostEvolution, *galacticFilter_"/>
!!]

self%labelID=nodeLabelRegister(char(label))
Expand All @@ -98,7 +114,7 @@ end function labelConstructorInternal
subroutine labelDestructor(self)
!!{
Destructor for the ``label'' galactic filter class.
!!}[<0;149;44m
!!}
implicit none
type(nodeOperatorLabel), intent(inout) :: self

Expand All @@ -117,7 +133,21 @@ subroutine labelTreeInitialize(self,node)
class(nodeOperatorLabel), intent(inout), target :: self
type (treeNode ), intent(inout), target :: node

if (self%galacticFilter_%passes(node)) &
if (self%onInitialize .and. self%galacticFilter_%passes(node)) &
& call nodeLabelSet(self%labelID,node)
return
end subroutine labelTreeInitialize

subroutine labelDifferentialEvolutionPost(self,node)
!!{
Initialize node branch tip indices.
!!}
use :: Nodes_Labels, only : nodeLabelSet
implicit none
class (nodeOperatorLabel), intent(inout) :: self
type (treeNode ), intent(inout) :: node

if (self%onPostEvolution .and. self%galacticFilter_%passes(node)) &
& call nodeLabelSet(self%labelID,node)
return
end subroutine labelDifferentialEvolutionPost
6 changes: 3 additions & 3 deletions source/nodes.property_extractor.tree_indices.F90
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
!! along with Galacticus. If not, see <http://www.gnu.org/licenses/>.

!!{
Contains a module which implements an ISM mass output analysis property extractor class.
Contains a module which implements merger tree index property extractor class.
!!}

!![
<nodePropertyExtractor name="nodePropertyExtractorIndicesTree">
<description>An ISM mass output analysis property extractor class.</description>
<description>A merger tree index property extractor class.</description>
</nodePropertyExtractor>
!!]
type, extends(nodePropertyExtractorIntegerScalar) :: nodePropertyExtractorIndicesTree
!!{
A stellar mass output analysis class.
A merger tree index property extractor class.
!!}
private
contains
Expand Down

0 comments on commit d08a189

Please sign in to comment.