From b5b68023ef964b251e13a79791ce095afb0dd7a5 Mon Sep 17 00:00:00 2001 From: Andrew Benson Date: Mon, 7 Oct 2024 07:52:35 -0700 Subject: [PATCH] feat: Add a `galacticFilter` that filters on maximum depth in the subhalo hierarchy --- ...lactic.filters.hierarchy_depth_maximum.F90 | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 source/galactic.filters.hierarchy_depth_maximum.F90 diff --git a/source/galactic.filters.hierarchy_depth_maximum.F90 b/source/galactic.filters.hierarchy_depth_maximum.F90 new file mode 100644 index 0000000000..fcade00ffb --- /dev/null +++ b/source/galactic.filters.hierarchy_depth_maximum.F90 @@ -0,0 +1,103 @@ +!! Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, +!! 2019, 2020, 2021, 2022, 2023, 2024 +!! Andrew Benson +!! +!! 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 . + +!!{ +Contains a module which implements a filter which passes only halos below a specified hierarchy depth. +!!} + + !![ + + A filter which passes only isolated halos. + + !!] + type, extends(galacticFilterClass) :: galacticFilterHierarchyDepthMaximum + !!{ + A galactic filter class which passes only isolated halos. + !!} + private + integer :: depthHierarchyLargest, nodeHierarchyLevelMaximumID + contains + procedure :: passes => hierarchyDepthMaximumPasses + end type galacticFilterHierarchyDepthMaximum + + interface galacticFilterHierarchyDepthMaximum + !!{ + Constructors for the ``hierarchyDepthMaximum'' galactic filter class. + !!} + module procedure hierarchyDepthMaximumConstructorParameters + module procedure hierarchyDepthMaximumConstructorInternal + end interface galacticFilterHierarchyDepthMaximum + +contains + + function hierarchyDepthMaximumConstructorParameters(parameters) result(self) + !!{ + Constructor for the ``hierarchyDepthMaximum'' galactic filter class which takes a parameter set as input. + !!} + use :: Input_Parameters, only : inputParameters + implicit none + type (galacticFilterHierarchyDepthMaximum) :: self + type (inputParameters ), intent(inout) :: parameters + integer :: depthHierarchyLargest + + !![ + + depthHierarchyLargest + parameters + The largest value of hierarchy maximum depth to pass. + + !!] + self=galacticFilterHierarchyDepthMaximum(depthHierarchyLargest) + !![ + + !!] + return + end function hierarchyDepthMaximumConstructorParameters + + function hierarchyDepthMaximumConstructorInternal(depthHierarchyLargest) result(self) + !!{ + Internal constructor for the ``hierarchyDepthMaximum'' galactic filter class. + !!} + implicit none + type (galacticFilterHierarchyDepthMaximum) :: self + integer , intent(in ) :: depthHierarchyLargest + !![ + + !!] + + !![ + + !!] + return + end function hierarchyDepthMaximumConstructorInternal + + logical function hierarchyDepthMaximumPasses(self,node) result(passes) + !!{ + Implement a galactic filter which passes only isolated halos. + !!} + use :: Galacticus_Nodes, only : nodeComponentBasic + implicit none + class(galacticFilterHierarchyDepthMaximum), intent(inout) :: self + type (treeNode ), intent(inout), target :: node + class(nodeComponentBasic ) , pointer :: basic + + basic => node %basic ( ) + passes = basic%integerRank0MetaPropertyGet(self%nodeHierarchyLevelMaximumID) <= self%depthHierarchyLargest + return + end function hierarchyDepthMaximumPasses