NimbleSM
NimbleSM is a solid mechanics simulation code for dynamic systems
Loading...
Searching...
No Matches
nimble_kokkos_block.h
Go to the documentation of this file.
1/*
2//@HEADER
3// ************************************************************************
4//
5// NimbleSM
6// Copyright 2018
7// National Technology & Engineering Solutions of Sandia, LLC (NTESS)
8//
9// Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government
10// retains certain rights in this software.
11//
12// Redistribution and use in source and binary forms, with or without
13// modification, are permitted provided that the following conditions are
14// met:
15//
16// 1. Redistributions of source code must retain the above copyright
17// notice, this list of conditions and the following disclaimer.
18//
19// 2. Redistributions in binary form must reproduce the above copyright
20// notice, this list of conditions and the following disclaimer in the
21// documentation and/or other materials provided with the distribution.
22//
23// 3. Neither the name of the Corporation nor the names of the
24// contributors may be used to endorse or promote products derived from
25// this software without specific prior written permission.
26//
27// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY EXPRESS OR IMPLIED
28// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
29// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
30// NO EVENT SHALL NTESS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
32// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37//
38// Questions? Contact David Littlewood (djlittl@sandia.gov)
39//
40// ************************************************************************
41//@HEADER
42*/
43
44#ifndef NIMBLE_KOKKOS_BLOCK_H
45#define NIMBLE_KOKKOS_BLOCK_H
46
47#include <map>
48#include <vector>
49
50#include "nimble_block_base.h"
51#include "nimble_element.h"
52#include "nimble_kokkos_defs.h"
53
54#ifdef NIMBLE_HAVE_DARMA
55#include "darma.h"
56#else
57#include <memory>
58#include <string>
59#include <vector>
60#endif
61
62namespace nimble {
63struct NGPLAMEData;
64}
65
66namespace nimble_kokkos {
67class MaterialFactory;
68}
69
70namespace nimble_kokkos {
71
73{
74 public:
75 Block() : BlockBase(), elem_conn_d("element_connectivity_d", 0), element_device_(nullptr), material_device_(nullptr)
76 {
77 }
78
79 ~Block() override
80 {
81 /* Kokkos::parallel_for(1, KOKKOS_LAMBDA(int) { */
82 /* element_device_->~Element(); */
83 /* }); */
84 if (element_device_ != nullptr) { Kokkos::kokkos_free(element_device_); }
85 if (material_device_ != nullptr) { Kokkos::kokkos_free(material_device_); }
86 }
87
88 void
89 Initialize(std::string const& model_material_parameters, int num_elements, MaterialFactory& factory);
90
91 void
92 InstantiateMaterialModel(int num_material_points, MaterialFactory& factory);
93
94 void
95 InstantiateElement() override;
96
97 std::shared_ptr<nimble::Element>
99 {
100 return element_;
101 }
102
105 {
106 return element_device_;
107 }
108
109 std::shared_ptr<nimble::Material>
111 {
112 return material_;
113 }
114
117 {
118 return material_device_;
119 }
120
123 {
124 return elem_conn_d;
125 }
126
127 std::shared_ptr<nimble::NGPLAMEData>
129 {
130 return ngp_lame_data_;
131 }
132
133 private:
134 /// \brief Element connectivity
136
137 /// \brief
138 nimble::Element* element_device_;
139
140 /// \brief
141 nimble::Material* material_device_;
142
143 /// \brief
144 std::shared_ptr<nimble::NGPLAMEData> ngp_lame_data_;
145};
146
147} // namespace nimble_kokkos
148
149#endif // NIMBLE_BLOCK_H
Definition nimble_block_base.h:58
std::shared_ptr< Material > material_
Definition nimble_block_base.h:118
BlockBase()=default
std::shared_ptr< Element > element_
Definition nimble_block_base.h:117
Abstract class for representing an element.
Definition nimble_element.h:57
Definition nimble_material.h:197
nimble::Material * GetDeviceMaterialModel()
Definition nimble_kokkos_block.h:116
std::shared_ptr< nimble::Element > GetHostElement()
Definition nimble_kokkos_block.h:98
void InstantiateElement() override
Definition nimble_kokkos_block.cc:68
DeviceElementConnectivityView & GetDeviceElementConnectivityView()
Definition nimble_kokkos_block.h:122
void Initialize(std::string const &model_material_parameters, int num_elements, MaterialFactory &factory)
Definition nimble_kokkos_block.cc:50
std::shared_ptr< nimble::NGPLAMEData > GetNGPLAMEData()
Definition nimble_kokkos_block.h:128
nimble::Element * GetDeviceElement()
Definition nimble_kokkos_block.h:104
std::shared_ptr< nimble::Material > GetHostMaterialModel()
Definition nimble_kokkos_block.h:110
void InstantiateMaterialModel(int num_material_points, MaterialFactory &factory)
Definition nimble_kokkos_block.cc:59
~Block() override
Definition nimble_kokkos_block.h:79
Block()
Definition nimble_kokkos_block.h:75
Definition nimble_kokkos_material_factory.h:59
Definition nimble_contact_manager.h:68
Kokkos::View< int *, kokkos_device > DeviceElementConnectivityView
Definition nimble_kokkos_defs.h:607
Definition kokkos_contact_manager.h:49