NimbleSM
NimbleSM is a solid mechanics simulation code for dynamic systems
Loading...
Searching...
No Matches
nimble_uq.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_UQ_H
45#define NIMBLE_UQ_H
46
47#include <map>
48#include <memory>
49#include <string>
50#include <vector>
51
52namespace nimble {
53class GenesisMesh;
54class ModelData;
55class Block;
56class MaterialFactory;
58
60{
61
62
63 public:
64 UqModel(int ndim, const GenesisMesh* mesh, ModelData* data);
65 virtual ~UqModel() = default;
66
67 void
68 ParseConfiguration(std::string const& line);
69
70 void
72 std::string const& line,
73 const int& block_id,
74 std::string const& nominal_params_string,
75 const std::shared_ptr<nimble::MaterialFactoryBase>& material_factory,
76 bool block_id_present,
77 std::map<int, std::shared_ptr<nimble::Block>>& blocks);
78
79 // pre time integration
80 void
81 Initialize();
82 // post time integration
83 void
85 // where all memory allocation is done
86 void
87 Allocate();
88 // pre ComputeInternalForce
89 void
90 Setup();
91 // construct approx_forces from the exact samples
92 void
94 // initialization
95 void
97 // - scale input
98 void
100 // - write scaled parameters
101 void
102 WriteSamples();
103 // Routine to perform in-situ processing over sample trajectories
104 void
106 const double* reference_coordinates,
107 int num_elem,
108 const int* elem_conn,
109 int block_id,
110 std::shared_ptr<nimble::Block>& block) {};
111 // write data
112 void
113 Write(double time) {};
114
115 // accessors
116 int
118 {
119 return nsamples_;
120 }
121 int
123 {
124 return parameter_order_.size();
125 }
126 int
128 {
129 return nexact_samples_;
130 }
131 bool
133 {
134 return initialized_;
135 }
136 std::vector<double*>&
138 {
139 return displacements_;
140 }
141 std::vector<double*>&
143 {
144 return velocities_;
145 }
146 std::vector<double*>&
148 {
149 return forces_;
150 }
151 std::map<std::string,double>
152 Parameters(int block_id, int sample_i)
153 {
154 return parameters_[block_id][sample_i];
155 }
156
157 private:
158 int ndims_; // from mesh
159 int nnodes_; // from mesh
160 int nblocks_; // from mesh
161 int nunknowns_; // nnodes*ndof
162 // parameter data
163 int nsamples_; // total additional
164 int nexact_samples_;
165 int napprox_samples_;
166 int nparameters_;
167 const GenesisMesh* mesh_;
168 ModelData* data_;
169 std::string samples_file_name_;
170 std::map<int,std::map<std::string,double>> nominal_parameters_;
171 std::map<int,std::map<std::string,double>> parameter_uncertainties_;
172 std::vector<std::pair<int,std::string>> parameter_order_;
173 std::vector<std::vector<double>> parameter_samples_; // ns,np
174 std::vector<std::vector<double>> interpolation_coefficients_; // na,np
175 // trajectory data
176 double* nominal_force_;
177 std::vector<double*> displacements_;
178 std::vector<double*> velocities_;
179 std::vector<double*> forces_;
180 std::map<int,std::vector<std::map<std::string,double>>> parameters_;
181 bool initialized_;
182};
183
184} // namespace nimble
185
186#endif // NIMBLE_UQ_H
Definition nimble_block.h:65
Definition nimble_genesis_mesh.h:59
Definition nimble_material_factory_base.h:61
Definition nimble_material_factory.h:52
Definition nimble_model_data.h:67
std::map< std::string, double > Parameters(int block_id, int sample_i)
Definition nimble_uq.h:152
bool Initialized() const
Definition nimble_uq.h:132
void Initialize()
Definition nimble_uq.cc:271
void PerformAnalyses(const double *reference_coordinates, int num_elem, const int *elem_conn, int block_id, std::shared_ptr< nimble::Block > &block)
Definition nimble_uq.h:105
std::vector< double * > & Displacements()
Definition nimble_uq.h:137
std::vector< double * > & Forces()
Definition nimble_uq.h:147
std::vector< double * > & Velocities()
Definition nimble_uq.h:142
void Setup()
Definition nimble_uq.cc:303
void WriteSamples()
Definition nimble_uq.cc:247
int GetNumExactSamples() const
Definition nimble_uq.h:127
void ApplyClosure()
Definition nimble_uq.cc:328
void ParseBlockInput(std::string const &line, const int &block_id, std::string const &nominal_params_string, const std::shared_ptr< nimble::MaterialFactoryBase > &material_factory, bool block_id_present, std::map< int, std::shared_ptr< nimble::Block > > &blocks)
Definition nimble_uq.cc:111
int GetNumSamples() const
Definition nimble_uq.h:117
void ScaleParameters()
Definition nimble_uq.cc:221
void ReadSamples()
Definition nimble_uq.cc:146
void Write(double time)
Definition nimble_uq.h:113
void ParseConfiguration(std::string const &line)
Definition nimble_uq.cc:93
void Allocate()
Definition nimble_uq.cc:282
int GetNumParameters() const
Definition nimble_uq.h:122
UqModel(int ndim, const GenesisMesh *mesh, ModelData *data)
Definition nimble_uq.cc:74
virtual ~UqModel()=default
Definition kokkos_contact_manager.h:49