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