VTK-m  2.0
CosmoTools.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 // Copyright (c) 2016, Los Alamos National Security, LLC
11 // All rights reserved.
12 //
13 // Copyright 2016. Los Alamos National Security, LLC.
14 // This software was produced under U.S. Government contract DE-AC52-06NA25396
15 // for Los Alamos National Laboratory (LANL), which is operated by
16 // Los Alamos National Security, LLC for the U.S. Department of Energy.
17 // The U.S. Government has rights to use, reproduce, and distribute this
18 // software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC
19 // MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE
20 // USE OF THIS SOFTWARE. If software is modified to produce derivative works,
21 // such modified software should be clearly marked, so as not to confuse it
22 // with the version available from LANL.
23 //
24 // Additionally, redistribution and use in source and binary forms, with or
25 // without modification, are permitted provided that the following conditions
26 // are met:
27 //
28 // 1. Redistributions of source code must retain the above copyright notice,
29 // this list of conditions and the following disclaimer.
30 // 2. Redistributions in binary form must reproduce the above copyright notice,
31 // this list of conditions and the following disclaimer in the documentation
32 // and/or other materials provided with the distribution.
33 // 3. Neither the name of Los Alamos National Security, LLC, Los Alamos
34 // National Laboratory, LANL, the U.S. Government, nor the names of its
35 // contributors may be used to endorse or promote products derived from
36 // this software without specific prior written permission.
37 //
38 // THIS SOFTWARE IS PROVIDED BY LOS ALAMOS NATIONAL SECURITY, LLC AND
39 // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
40 // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LOS ALAMOS
42 // NATIONAL SECURITY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
46 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
48 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 //============================================================================
50 
51 #ifndef vtk_m_worklet_CosmoTools_h
52 #define vtk_m_worklet_CosmoTools_h
53 
54 #include <vtkm/cont/ArrayHandle.h>
56 #include <vtkm/cont/Field.h>
57 
61 
62 namespace vtkm
63 {
64 namespace worklet
65 {
66 
68 {
69 public:
70  // Run the halo finder and then the NxN MBP center finder
71  template <typename FieldType, typename StorageType>
75  const vtkm::Id nParticles,
76  const FieldType particleMass,
77  const vtkm::Id minHaloSize,
78  const FieldType linkingLen,
82  {
83  // Constructor gets particle locations, particle mass and min halo size
85  nParticles, particleMass, minHaloSize, linkingLen, xLocation, yLocation, zLocation);
86 
87  // Find the halos within the particles and the MBP center of each halo
88  cosmo.HaloFinder(resultHaloId, resultMBP, resultPot);
89  }
90 
91  // Run MBP on a single halo of particles using the N^2 algorithm
92  template <typename FieldType, typename StorageType>
96  const vtkm::Id nParticles,
97  const FieldType particleMass,
99  {
100  // Constructor gets particle locations and particle mass
102  nParticles, particleMass, xLocation, yLocation, zLocation);
103 
104  // Most Bound Particle N x N algorithm
105  FieldType nxnPotential;
106  vtkm::Id nxnMBP = cosmo.MBPCenterFinderNxN(&nxnPotential);
107 
108  nxnResult.first = nxnMBP;
109  nxnResult.second = nxnPotential;
110  }
111 
112  // Run MBP on a single halo of particles using MxN estimation algorithm
113  template <typename FieldType, typename StorageType>
117  const vtkm::Id nParticles,
118  const FieldType particleMass,
120  {
121  // Constructor gets particle locations and particle mass
123  nParticles, particleMass, xLocation, yLocation, zLocation);
124 
125  // Most Bound Particle M x N algorithm with binning estimates
126  FieldType mxnPotential;
127  vtkm::Id mxnMBP = cosmo.MBPCenterFinderMxN(&mxnPotential);
128 
129  mxnResult.first = mxnMBP;
130  mxnResult.second = mxnPotential;
131  }
132 };
133 }
134 } // namespace vtkm::worklet
135 
136 #endif // vtk_m_worklet_CosmoTools_h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
ArrayHandle.h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
CosmoToolsHaloFinder.h
vtkm::worklet::CosmoTools
Definition: CosmoTools.h:67
DeviceAdapterAlgorithm.h
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::worklet::CosmoTools::RunMBPCenterFinderMxN
void RunMBPCenterFinderMxN(vtkm::cont::ArrayHandle< FieldType, StorageType > xLocation, vtkm::cont::ArrayHandle< FieldType, StorageType > yLocation, vtkm::cont::ArrayHandle< FieldType, StorageType > zLocation, const vtkm::Id nParticles, const FieldType particleMass, vtkm::Pair< vtkm::Id, FieldType > &mxnResult)
Definition: CosmoTools.h:114
CosmoToolsCenterFinder.h
vtkm::Pair::first
FirstType first
The pair's first object.
Definition: Pair.h:50
vtkm::worklet::cosmotools::CosmoTools
Definition: cosmotools/CosmoTools.h:172
CosmoTools.h
vtkm::worklet::cosmotools::CosmoTools::HaloFinder
void HaloFinder(vtkm::cont::ArrayHandle< vtkm::Id > &resultHaloId, vtkm::cont::ArrayHandle< vtkm::Id > &resultMBP, vtkm::cont::ArrayHandle< T > &resultPot)
Definition: CosmoToolsHaloFinder.h:72
Field.h
vtkm::worklet::cosmotools::CosmoTools::MBPCenterFinderMxN
vtkm::Id MBPCenterFinderMxN(T *mxnPotential)
Definition: CosmoToolsCenterFinder.h:73
vtkm::Pair
A vtkm::Pair is essentially the same as an STL pair object except that the methods (constructors and ...
Definition: Pair.h:29
vtkm::Pair::second
SecondType second
The pair's second object.
Definition: Pair.h:55
vtkm::worklet::CosmoTools::RunMBPCenterFinderNxN
void RunMBPCenterFinderNxN(vtkm::cont::ArrayHandle< FieldType, StorageType > xLocation, vtkm::cont::ArrayHandle< FieldType, StorageType > yLocation, vtkm::cont::ArrayHandle< FieldType, StorageType > zLocation, const vtkm::Id nParticles, const FieldType particleMass, vtkm::Pair< vtkm::Id, FieldType > &nxnResult)
Definition: CosmoTools.h:93
vtkm::worklet::cosmotools::CosmoTools::MBPCenterFinderNxN
vtkm::Id MBPCenterFinderNxN(T *nxnPotential)
Definition: CosmoToolsCenterFinder.h:381
vtkm::worklet::CosmoTools::RunHaloFinder
void RunHaloFinder(vtkm::cont::ArrayHandle< FieldType, StorageType > &xLocation, vtkm::cont::ArrayHandle< FieldType, StorageType > &yLocation, vtkm::cont::ArrayHandle< FieldType, StorageType > &zLocation, const vtkm::Id nParticles, const FieldType particleMass, const vtkm::Id minHaloSize, const FieldType linkingLen, vtkm::cont::ArrayHandle< vtkm::Id > &resultHaloId, vtkm::cont::ArrayHandle< vtkm::Id > &resultMBP, vtkm::cont::ArrayHandle< FieldType > &resultPot)
Definition: CosmoTools.h:72