NimbleSM
NimbleSM is a solid mechanics simulation code for dynamic systems
Loading...
Searching...
No Matches
nimble Namespace Reference

Namespaces

namespace  details
 
namespace  quanta
 
namespace  serialization
 

Classes

class  Block
 
class  BlockBase
 
struct  BlockData
 
class  BlockMaterialInterfaceBase
 
class  BlockMaterialInterfaceFactoryBase
 
struct  BlockProperties
 
class  BoundaryCondition
 
class  BoundaryConditionManager
 
class  BvhContactManager
 
struct  CGScratchSpace
 
class  CommandLineConfiguration
 
struct  ComputeInternalForceFunctor
 
class  ContactEntity
 
class  ContactInterface
 
class  ContactManager
 
class  CRSMatrixContainer
 
class  DataManager
 
class  ElasticMaterial
 
class  Element
 Abstract class for representing an element. More...
 
class  ExodusOutput
 
class  ExplicitTimeIntegrator
 
class  Field
 
struct  FieldIds
 
class  GenesisMesh
 
class  HexElement
 Class for an 8-node hexahedral element. More...
 
class  IntegratorBase
 
class  KokkosContactManager
 
class  Material
 
class  MaterialFactory
 
class  MaterialFactoryBase
 
class  MaterialParameters
 
class  MatrixContainer
 
class  ModelData
 
class  ModelDataBase
 
class  mpicontext
 
struct  NarrowphaseFunc
 
struct  NarrowphaseResult
 
class  NeohookeanMaterial
 
class  NimbleApplication
 
class  Parser
 
struct  PenaltyContactEnforcement
 
class  ProfilingTimer
 
class  QuasistaticTimeIntegrator
 
struct  ReductionClique_t
 
class  SerialContactManager
 
class  TimeKeeper
 
class  Timer
 
struct  TimingInfo
 
class  TpetraContainer
 
class  TpetraMatrixContainer
 
class  UqModel
 
class  VectorCommunicator
 
class  View
 
class  Viewify
 

Typedefs

typedef int comm_type
 

Enumerations

enum  Relation { UNDEFINED_RELATION = 0 , NODE , ELEMENT , GLOBAL }
 
enum  Length {
  LENGTH_0 = 0 , LENGTH_1 = 1 , LENGTH_2 = 2 , LENGTH_3 = 3 ,
  LENGTH_4 = 4 , LENGTH_5 = 5 , LENTGH_6 = 6 , LENGTH_7 = 7 ,
  LENGTH_8 = 8 , LENGTH_9 = 9 , LENGTH_10 = 10 , LENGTH_11 = 11 ,
  LENGTH_12 = 12 , LENGTH_13 = 13 , LENGTH_14 = 14 , LENGTH_15 = 15 ,
  LENGTH_16 = 16 , LENGTH_17 = 17 , LENGTH_18 = 18 , LENGTH_19 = 19 ,
  LENGTH_20 = 20 , SCALAR , VECTOR , SYMMETRIC_TENSOR ,
  FULL_TENSOR , UNDEFINED_LENGTH
}
 
enum  Step { UNDEFINED_STEP = 0 , STEP_N , STEP_NP1 }
 

Functions

std::vector< int > PackIDSpace (const std::vector< int > &raw_node_ids, int max_nodes_assigned_to_a_rank, const mpicontext &context)
 
int GetMaximumNodeId (const std::vector< int > &global_node_ids, const mpicontext &context)
 
std::unique_ptr< int[]> GetNumberOfNodesAssignedToEachRank (const std::vector< int > &global_node_ids, const mpicontext &context)
 
void EnsureCheckpoint (const mpicontext &context, const std::string &message)
 
template<class Key, class Val>
std::vector< std::pair< Key, std::vector< Val > > > GroupConsecutive (const std::vector< std::pair< Key, Val > > &lst)
 
NIMBLE_INLINE_FUNCTION double TriangleArea (double pt_1_x, double pt_1_y, double pt_1_z, double pt_2_x, double pt_2_y, double pt_2_z, double pt_3_x, double pt_3_y, double pt_3_z)
 
NIMBLE_INLINE_FUNCTION double PointEdgeClosestPointFindT (double const p1[], double const p2[], double const p[])
 
NIMBLE_INLINE_FUNCTION double PointEdgeClosestPointFindDistanceSquared (double const p1[], double const p2[], double const p[], double t)
 
void ParseContactCommand (std::string const &command, std::vector< std::string > &primary_block_names, std::vector< std::string > &secondary_block_names, double &penalty_parameter)
 
template<typename ArgT>
void SerializeContactFaces (int num_entities, ArgT contact_entities, std::vector< char > &buffer)
 
template<typename ArgT>
void UnserializeContactFaces (int num_entities, ArgT contact_entities, std::vector< char > &buffer)
 
std::shared_ptr< nimble::ContactManagerGetContactManager (std::shared_ptr< ContactInterface > interface, nimble::DataManager &data_manager)
 
int LengthToInt (Length length, int dim)
 
std::string AddIntegrationPointPrefix (std::string label, int ipt_number)
 
std::string RemoveIntegrationPointPrefix (std::string label)
 
bool HasIntegrationPointPrefix (std::string label)
 
int LabelToIntegrationPointNumber (std::string label)
 
std::vector< std::string > GetComponentLabels (std::string label, Length length, int dim)
 
std::string GetComponentLabel (std::string label, Length length, int dim, int component_index, int ipt)
 
Length LabelToLength (std::string label, std::map< int, Field > const &data_fields, int dim)
 
void PopulateDiagonalPreconditioner (const CRSMatrixContainer &A, CRSMatrixContainer &M)
 
bool CG_SolveSystem (nimble::CRSMatrixContainer &A, const double *b, CGScratchSpace &cg_scratch, double *x, int &num_iterations, double cg_tol, int max_iterations)
 
double InnerProduct (unsigned int num_entries, const double *vec_1, const double *vec_2)
 
double InnerProduct (const std::vector< double > &vec_1, const std::vector< double > &vec_2)
 
void LU_Decompose (int num_entries, MatrixContainer &mat, int *index)
 
void LU_Solve (int num_entries, MatrixContainer &mat, double *vec, int *index)
 
void LU_SolveSystem (int num_entries, MatrixContainer &mat, double *vec, int *scratch)
 
void DetermineTangentMatrixNonzeroStructure (GenesisMesh const &mesh, std::vector< int > const &linear_system_node_ids, std::vector< int > &i_index, std::vector< int > &j_index)
 
template void ModelData::EmplaceBlocks< nimble::Block > (nimble::DataManager &data_manager, const std::shared_ptr< nimble::MaterialFactoryBase > &material_factory_base)
 
std::string IOFileName (std::string const &serial_name, std::string const &extension, std::string const &label, int my_rank, int num_ranks)
 
void IOFileNameThreadSafe (char const *const serial_file_name, char const *const extension, char const *const label, int my_mpi_rank, int mpi_num_ranks, int my_thread_rank, int num_threads, char *const file_name)
 
std::vector< std::string > tokenize_string (const std::string &s)
 
double string_to_double (const std::string &s)
 
std::string NimbleVersion ()
 
template<std::size_t N>
details::AXPYResult< N > operator* (double alpha, const nimble::Viewify< N > &A)
 
std::list< std::string > split (std::string line)
 

Variables

constexpr int MAX_C_STR_SIZE = 256
 

Typedef Documentation

◆ comm_type

typedef int nimble::comm_type

Enumeration Type Documentation

◆ Length

Enumerator
LENGTH_0 
LENGTH_1 
LENGTH_2 
LENGTH_3 
LENGTH_4 
LENGTH_5 
LENTGH_6 
LENGTH_7 
LENGTH_8 
LENGTH_9 
LENGTH_10 
LENGTH_11 
LENGTH_12 
LENGTH_13 
LENGTH_14 
LENGTH_15 
LENGTH_16 
LENGTH_17 
LENGTH_18 
LENGTH_19 
LENGTH_20 
SCALAR 
VECTOR 
SYMMETRIC_TENSOR 
FULL_TENSOR 
UNDEFINED_LENGTH 
66{
67 LENGTH_0 = 0,
68 LENGTH_1 = 1,
69 LENGTH_2 = 2,
70 LENGTH_3 = 3,
71 LENGTH_4 = 4,
72 LENGTH_5 = 5,
73 LENTGH_6 = 6,
74 LENGTH_7 = 7,
75 LENGTH_8 = 8,
76 LENGTH_9 = 9,
77 LENGTH_10 = 10,
78 LENGTH_11 = 11,
79 LENGTH_12 = 12,
80 LENGTH_13 = 13,
81 LENGTH_14 = 14,
82 LENGTH_15 = 15,
83 LENGTH_16 = 16,
84 LENGTH_17 = 17,
85 LENGTH_18 = 18,
86 LENGTH_19 = 19,
87 LENGTH_20 = 20,
88 SCALAR,
89 VECTOR,
93};
@ LENGTH_18
Definition nimble_data_utils.h:85
@ LENGTH_8
Definition nimble_data_utils.h:75
@ LENGTH_20
Definition nimble_data_utils.h:87
@ LENGTH_10
Definition nimble_data_utils.h:77
@ LENGTH_3
Definition nimble_data_utils.h:70
@ LENGTH_14
Definition nimble_data_utils.h:81
@ LENGTH_15
Definition nimble_data_utils.h:82
@ LENGTH_17
Definition nimble_data_utils.h:84
@ LENGTH_1
Definition nimble_data_utils.h:68
@ LENGTH_13
Definition nimble_data_utils.h:80
@ SCALAR
Definition nimble_data_utils.h:88
@ LENGTH_16
Definition nimble_data_utils.h:83
@ LENGTH_9
Definition nimble_data_utils.h:76
@ LENGTH_12
Definition nimble_data_utils.h:79
@ LENGTH_7
Definition nimble_data_utils.h:74
@ LENGTH_5
Definition nimble_data_utils.h:72
@ VECTOR
Definition nimble_data_utils.h:89
@ LENGTH_19
Definition nimble_data_utils.h:86
@ SYMMETRIC_TENSOR
Definition nimble_data_utils.h:90
@ LENGTH_0
Definition nimble_data_utils.h:67
@ LENGTH_11
Definition nimble_data_utils.h:78
@ LENTGH_6
Definition nimble_data_utils.h:73
@ LENGTH_4
Definition nimble_data_utils.h:71
@ UNDEFINED_LENGTH
Definition nimble_data_utils.h:92
@ FULL_TENSOR
Definition nimble_data_utils.h:91
@ LENGTH_2
Definition nimble_data_utils.h:69

◆ Relation

Enumerator
UNDEFINED_RELATION 
NODE 
ELEMENT 
GLOBAL 
58{
60 NODE,
61 ELEMENT,
62 GLOBAL
63};
@ NODE
Definition nimble_data_utils.h:60
@ GLOBAL
Definition nimble_data_utils.h:62
@ UNDEFINED_RELATION
Definition nimble_data_utils.h:59
@ ELEMENT
Definition nimble_data_utils.h:61

◆ Step

Enumerator
UNDEFINED_STEP 
STEP_N 
STEP_NP1 
96{
98 STEP_N,
100};
@ UNDEFINED_STEP
Definition nimble_data_utils.h:97
@ STEP_NP1
Definition nimble_data_utils.h:99
@ STEP_N
Definition nimble_data_utils.h:98

Function Documentation

◆ AddIntegrationPointPrefix()

std::string nimble::AddIntegrationPointPrefix ( std::string label,
int ipt_number )
86{
87 std::string modified_label;
88 std::stringstream ss;
89 ss << ipt_number;
90 if (ss.str().size() == 1) {
91 modified_label = "ipt0" + ss.str() + "_" + label;
92 } else {
93 modified_label = "ipt" + ss.str() + "_" + label;
94 }
95 return modified_label;
96}

◆ CG_SolveSystem()

bool nimble::CG_SolveSystem ( nimble::CRSMatrixContainer & A,
const double * b,
CGScratchSpace & cg_scratch,
double * x,
int & num_iterations,
double cg_tol,
int max_iterations )
163{
164 // see "An Introduction to the Conjugate Gradient Method Without the Agonizing
165 // Pain", J.R. Shewchuk, 1994.
166
167 double alpha, beta, delta_old, delta_new;
168 unsigned int num_entries = A.NumRows();
169 cg_scratch.Resize(num_entries);
170 double* d = cg_scratch.d.data();
171 double* r = cg_scratch.r.data();
172 double* s = cg_scratch.s.data();
173 double* q = cg_scratch.q.data();
174
175 // diagonal preconditioner
176 CRSMatrixContainer& M = cg_scratch.M;
178
179 // r = b - Ax
180 A.MatVec(x, q);
181 for (unsigned int i = 0; i < num_entries; i++) { r[i] = b[i] - q[i]; }
182
183 // d = M^-1 r
184 M.DiagonalMatrixMatVec(r, d);
185
186 // delta_new = r^T d
187 // delta_old = delta_new
188 delta_new = delta_old = InnerProduct(num_entries, r, d);
189 double tolerance = cg_tol * delta_old;
190
191 int iteration = 0;
192
193 while (delta_new > tolerance && iteration < max_iterations) {
194 // q = Ad
195 A.MatVec(d, q);
196
197 // alpha = delta_new / (d^T q)
198 alpha = delta_new / InnerProduct(num_entries, d, q);
199
200 // x = x + alpha * d
201 for (unsigned int i = 0; i < num_entries; i++) { x[i] += alpha * d[i]; }
202
203 if (iteration % 50 == 0) {
204 // r = b - Ax
205 A.MatVec(x, q); // here, q is just a place to store Ax
206 for (unsigned int i = 0; i < num_entries; i++) { r[i] = b[i] - q[i]; }
207 } else {
208 // r = r - alpha * q
209 for (unsigned int i = 0; i < num_entries; i++) { r[i] -= alpha * q[i]; }
210 }
211
212 // s = M^-1 r
213 M.DiagonalMatrixMatVec(r, s);
214
215 // delta_old = delta_new
216 delta_old = delta_new;
217
218 // delta_new = r^T s
219 delta_new = InnerProduct(num_entries, r, s);
220
221 // beta = delta_new / delta_old
222 beta = delta_new / delta_old;
223
224 // d = s + beta * d
225 for (unsigned int i = 0; i < num_entries; i++) { d[i] = s[i] + beta * d[i]; }
226
227 iteration += 1;
228 }
229
230 num_iterations = iteration;
231 bool success = true;
232 if (iteration == max_iterations) { success = false; }
233 return success;
234}
Definition nimble_linear_solver.h:119
void MatVec(const double *vec, double *result) const
Definition nimble_linear_solver.cc:118
void DiagonalMatrixMatVec(const double *vec, double *result) const
Definition nimble_linear_solver.cc:125
int NumRows() const
Definition nimble_linear_solver.h:158
double InnerProduct(unsigned int num_entries, const double *vec_1, const double *vec_2)
Definition nimble_linear_solver.h:215
void PopulateDiagonalPreconditioner(const CRSMatrixContainer &A, CRSMatrixContainer &M)
Definition nimble_linear_solver.cc:138
std::vector< double > q
Definition nimble_linear_solver.h:262
std::vector< double > d
Definition nimble_linear_solver.h:259
std::vector< double > r
Definition nimble_linear_solver.h:260
void Resize(int len)
Definition nimble_linear_solver.h:246
CRSMatrixContainer M
Definition nimble_linear_solver.h:263
std::vector< double > s
Definition nimble_linear_solver.h:261

◆ DetermineTangentMatrixNonzeroStructure()

void nimble::DetermineTangentMatrixNonzeroStructure ( GenesisMesh const & mesh,
std::vector< int > const & linear_system_node_ids,
std::vector< int > & i_index,
std::vector< int > & j_index )
54{
55 std::vector<int> block_ids = mesh.GetBlockIds();
56 int dim = mesh.GetDim();
57 int num_rows = linear_system_node_ids.size() * dim;
58
59 // column indexes for the nonzeros in each row
60 std::vector<std::set<int>> nonzeros(num_rows);
61
62 for (auto const& block_id : block_ids) {
63 int num_elem = mesh.GetNumElementsInBlock(block_id);
64 int num_nodes_per_elem = mesh.GetNumNodesPerElement(block_id);
65 std::vector<int> linear_system_dof(num_nodes_per_elem * dim);
66 int const* elem_conn = mesh.GetConnectivity(block_id);
67 for (int i_elem = 0; i_elem < num_elem; i_elem++) {
68 for (int i_node = 0; i_node < num_nodes_per_elem; i_node++) {
69 for (int i_dim = 0; i_dim < dim; i_dim++) {
70 linear_system_dof[i_node * dim + i_dim] =
71 linear_system_node_ids[elem_conn[num_nodes_per_elem * i_elem + i_node]] * dim + i_dim;
72 }
73 }
74 int row, col;
75 for (int i = 0; i < num_nodes_per_elem * dim; i++) {
76 for (int j = 0; j < num_nodes_per_elem * dim; j++) {
77 row = linear_system_dof[i];
78 col = linear_system_dof[j];
79 nonzeros[row].insert(col);
80 nonzeros[col].insert(row);
81 }
82 }
83 }
84 }
85
86 // i_index and j_index are arrays containing the row and column indices,
87 // respectively, for each nonzero
88 int num_entries(0);
89 for (int i_row = 0; i_row < num_rows; i_row++) { num_entries += nonzeros[i_row].size(); }
90 i_index.resize(num_entries);
91 j_index.resize(num_entries);
92 int index(0);
93 for (int i_row = 0; i_row < num_rows; i_row++) {
94 for (auto const& entry : nonzeros[i_row]) {
95 i_index[index] = i_row;
96 j_index[index++] = entry;
97 }
98 }
99}

◆ EnsureCheckpoint()

void nimble::EnsureCheckpoint ( const mpicontext & context,
const std::string & message )

◆ GetComponentLabel()

std::string nimble::GetComponentLabel ( std::string label,
Length length,
int dim,
int component_index,
int ipt )
211{
212 if (length == VECTOR) {
213 switch (component_index) {
214 case 0: label += "_x"; break;
215 case 1: label += "_y"; break;
216 case 2: label += "_z"; break;
217 default: throw std::invalid_argument("\nError in GetComponentLabel().\n");
218 }
219 } else if (length == SYMMETRIC_TENSOR) {
220 if (dim == 2) {
221 switch (component_index) {
222 case 0: label += "_xx"; break;
223 case 1: label += "_yy"; break;
224 case 2: label += "_xy"; break;
225 default: throw std::invalid_argument("\nError in GetComponentLabel().\n");
226 }
227 } else if (dim == 3) {
228 switch (component_index) {
229 case 0: label += "_xx"; break;
230 case 1: label += "_yy"; break;
231 case 2: label += "_zz"; break;
232 case 3: label += "_xy"; break;
233 case 4: label += "_yz"; break;
234 case 5: label += "_zx"; break;
235 default: throw std::invalid_argument("\nError in GetComponentLabel().\n");
236 }
237 }
238 } else if (length == FULL_TENSOR) {
239 if (dim == 2) {
240 switch (component_index) {
241 case 0: label += "_xx"; break;
242 case 1: label += "_yy"; break;
243 case 2: label += "_xy"; break;
244 case 3: label += "_yx"; break;
245 default: throw std::invalid_argument("\nError in GetComponentLabel().\n");
246 }
247 } else if (dim == 3) {
248 switch (component_index) {
249 case 0: label += "_xx"; break;
250 case 1: label += "_yy"; break;
251 case 2: label += "_zz"; break;
252 case 3: label += "_xy"; break;
253 case 4: label += "_yz"; break;
254 case 5: label += "_zx"; break;
255 case 6: label += "_yx"; break;
256 case 7: label += "_zy"; break;
257 case 8: label += "_xz"; break;
258 default: throw std::invalid_argument("\nError in GetComponentLabel().\n");
259 }
260 }
261 }
262
263 label = AddIntegrationPointPrefix(label, ipt);
264
265 return label;
266}
std::string AddIntegrationPointPrefix(std::string label, int ipt_number)
Definition nimble_data_utils.cc:85

◆ GetComponentLabels()

std::vector< std::string > nimble::GetComponentLabels ( std::string label,
Length length,
int dim )
160{
161 std::vector<std::string> labels;
162 if (length == SCALAR) {
163 labels.push_back(label);
164 } else if (length == VECTOR) {
165 labels.push_back(label + "_x");
166 labels.push_back(label + "_y");
167 if (dim == 3) { labels.push_back(label + "_z"); }
168 } else if (length == SYMMETRIC_TENSOR) {
169 if (dim == 2) {
170 labels.push_back(label + "_xx");
171 labels.push_back(label + "_yy");
172 labels.push_back(label + "_xy");
173 } else if (dim == 3) {
174 labels.push_back(label + "_xx");
175 labels.push_back(label + "_yy");
176 labels.push_back(label + "_zz");
177 labels.push_back(label + "_xy");
178 labels.push_back(label + "_yz");
179 labels.push_back(label + "_zx");
180 }
181 } else if (length == FULL_TENSOR) {
182 if (dim == 2) {
183 labels.push_back(label + "_xx");
184 labels.push_back(label + "_yy");
185 labels.push_back(label + "_xy");
186 labels.push_back(label + "_xy");
187 } else if (dim == 3) {
188 labels.push_back(label + "_xx");
189 labels.push_back(label + "_yy");
190 labels.push_back(label + "_zz");
191 labels.push_back(label + "_xy");
192 labels.push_back(label + "_yz");
193 labels.push_back(label + "_zx");
194 labels.push_back(label + "_yx");
195 labels.push_back(label + "_zy");
196 labels.push_back(label + "_xz");
197 }
198 } else {
199 int num_labels = static_cast<int>(length);
200 for (int i = 0; i < num_labels; i++) {
201 std::stringstream ss;
202 ss << "_" << i + 1;
203 labels.push_back(label + ss.str());
204 }
205 }
206 return labels;
207}

◆ GetContactManager()

std::shared_ptr< nimble::ContactManager > nimble::GetContactManager ( std::shared_ptr< ContactInterface > interface,
nimble::DataManager & data_manager )
153{
154 if (!data_manager.GetParser().HasContact()) return nullptr;
155
156#ifdef NIMBLE_HAVE_BVH
157 if (data_manager.GetParser().UseVT()) {
158 return std::make_shared<nimble::BvhContactManager>(
159 interface, data_manager, data_manager.GetParser().ContactDicing(),
160 data_manager.GetParser().ContactSplitting());
161 }
162#endif
163
164#if defined(NIMBLE_HAVE_ARBORX)
165#if defined(ARBORX_ENABLE_MPI) && defined(NIMBLE_HAVE_MPI)
166 return std::make_shared<nimble::ArborXParallelContactManager>(interface, data_manager);
167#else
168 return std::make_shared<nimble::ArborXSerialContactManager>(interface, data_manager);
169#endif
170#endif
171
172 return std::make_shared<nimble::ContactManager>(interface, data_manager);
173}
const nimble::Parser & GetParser() const
Return constant reference to parser information.
Definition nimble_data_manager.h:101
bool HasContact() const
Definition nimble_parser.h:190
bool UseVT() const
Indicate whether VT is used.
Definition nimble_parser.h:307

◆ GetMaximumNodeId()

int nimble::GetMaximumNodeId ( const std::vector< int > & global_node_ids,
const mpicontext & context )

◆ GetNumberOfNodesAssignedToEachRank()

std::unique_ptr< int[]> nimble::GetNumberOfNodesAssignedToEachRank ( const std::vector< int > & global_node_ids,
const mpicontext & context )

◆ GroupConsecutive()

template<class Key, class Val>
std::vector< std::pair< Key, std::vector< Val > > > nimble::GroupConsecutive ( const std::vector< std::pair< Key, Val > > & lst)
81{
82 if (lst.size() == 0) return {};
83 std::vector<int> key_ids;
84 key_ids.reserve(lst.size() + 1);
85 const Key* group_key = &lst[0].first;
86 int max_key_id = 0;
87 int lst_size = lst.size();
88 for (const std::pair<Key, Val>& p : lst) {
89 if (p.first != *group_key) {
90 ++max_key_id;
91 group_key = &p.first;
92 }
93 key_ids.push_back(max_key_id);
94 }
95 key_ids.push_back(max_key_id + 1);
96 std::vector<std::pair<Key, std::vector<Val>>> groups;
97 groups.reserve(max_key_id + 1);
98 {
99 int prev_key_id = 0;
100 int group_size = 1;
101 for (int i = 1; i <= lst_size; ++i) {
102 if (key_ids[i] != prev_key_id) {
103 groups.emplace_back(lst[i - 1].first, std::vector<Val>(group_size));
104 auto& new_elem = groups.back();
105 const std::pair<Key, Val>* src_ptr = &lst[i - group_size];
106 for (Val& q : new_elem.second) {
107 q = src_ptr->second;
108 ++src_ptr;
109 }
110 group_size = 1;
111 prev_key_id = key_ids[i];
112 } else {
113 ++group_size;
114 }
115 }
116 }
117 return groups;
118}

◆ HasIntegrationPointPrefix()

bool nimble::HasIntegrationPointPrefix ( std::string label)
125{
126 std::string label_without_prefix = RemoveIntegrationPointPrefix(label);
127 if (label == label_without_prefix) { return false; }
128 return true;
129}
std::string RemoveIntegrationPointPrefix(std::string label)
Definition nimble_data_utils.cc:99

◆ InnerProduct() [1/2]

double nimble::InnerProduct ( const std::vector< double > & vec_1,
const std::vector< double > & vec_2 )
inline
228{
229 return InnerProduct(vec_1.size(), &vec_1[0], &vec_2[0]);
230}

◆ InnerProduct() [2/2]

double nimble::InnerProduct ( unsigned int num_entries,
const double * vec_1,
const double * vec_2 )
inline
216{
217 double result(0.0);
218 for (unsigned int i = 0; i < num_entries; i++) { result += vec_1[i] * vec_2[i]; }
219#ifdef NIMBLE_HAVE_MPI
220 double restmp = result;
221 MPI_Allreduce(&restmp, &result, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
222#endif
223 return result;
224}

◆ IOFileName()

std::string nimble::IOFileName ( std::string const & serial_name,
std::string const & extension,
std::string const & label,
int my_rank,
int num_ranks )
64{
65 if (serial_name == "none") { return serial_name; }
66
67 std::string file_name = serial_name;
68 size_t pos = file_name.rfind(".g");
69 if (pos != std::string::npos) { file_name = file_name.substr(0, pos); }
70 pos = file_name.rfind(".e");
71 if (pos != std::string::npos) { file_name = file_name.substr(0, pos); }
72 if (!label.empty()) { file_name += "." + label; }
73 file_name += "." + extension;
74 if (num_ranks > 1) {
75 std::stringstream num_ranks_ss;
76 num_ranks_ss << num_ranks;
77 std::stringstream my_rank_ss;
78 my_rank_ss << my_rank;
79 int num_zero_padding = num_ranks_ss.str().size() - my_rank_ss.str().size();
80 std::stringstream ss;
81 ss << file_name << "." << num_ranks << ".";
82 for (int i = 0; i < num_zero_padding; i++) { ss << 0; }
83 ss << my_rank;
84 // file_name += ss.str(); // DJL not thread safe??
85 ss >> file_name;
86 }
87 return file_name;
88}

◆ IOFileNameThreadSafe()

void nimble::IOFileNameThreadSafe ( char const *const serial_file_name,
char const *const extension,
char const *const label,
int my_mpi_rank,
int mpi_num_ranks,
int my_thread_rank,
int num_threads,
char *const file_name )
100{
101 // copy the input file name to the output file name
102 strcpy(file_name, serial_file_name);
103
104 // strip off .g or .e suffix
105 size_t len = strlen(file_name);
106 if (len > 2) { file_name[len - 2] = '\0'; }
107
108 // add the label, if any, to the file_name
109 size_t label_len = strlen(label);
110 if (label_len > 0) {
111 strcat(file_name, ".");
112 strcat(file_name, label);
113 }
114
115 // add the extension to the file name
116 size_t extension_len = strlen(extension);
117 if (extension_len > 0) {
118 strcat(file_name, ".");
119 strcat(file_name, extension);
120 }
121
122 if (mpi_num_ranks > 1) {
123 // total number of mpi ranks
124 char mpi_num_ranks_str[MAX_C_STR_SIZE];
125 sprintf(mpi_num_ranks_str, "%d", mpi_num_ranks);
126 strcat(file_name, ".");
127 strcat(file_name, mpi_num_ranks_str);
128
129 // padded mpi rank number
130 char my_mpi_rank_str[MAX_C_STR_SIZE];
131 sprintf(my_mpi_rank_str, "%d", my_mpi_rank);
132 size_t required_str_len = strlen(mpi_num_ranks_str);
133 size_t current_str_len = strlen(my_mpi_rank_str);
134 strcat(file_name, ".");
135 size_t num_zero_padding = required_str_len - current_str_len;
136 for (size_t i = 0; i < num_zero_padding; i++) { strcat(file_name, "0"); }
137 strcat(file_name, my_mpi_rank_str);
138 }
139
140 if (num_threads > 1) {
141 // total number of threads
142 char num_threads_str[MAX_C_STR_SIZE];
143 sprintf(num_threads_str, "%d", num_threads);
144 strcat(file_name, ".");
145 strcat(file_name, num_threads_str);
146
147 // padded thread number
148 char my_thread_rank_str[MAX_C_STR_SIZE];
149 sprintf(my_thread_rank_str, "%d", my_thread_rank);
150 size_t required_str_len = strlen(num_threads_str);
151 size_t current_str_len = strlen(my_thread_rank_str);
152 strcat(file_name, ".");
153 size_t num_zero_padding = required_str_len - current_str_len;
154 for (size_t i = 0; i < num_zero_padding; i++) { strcat(file_name, "0"); }
155 strcat(file_name, my_thread_rank_str);
156 }
157}
constexpr int MAX_C_STR_SIZE
Definition nimble_parser.h:66

◆ LabelToIntegrationPointNumber()

int nimble::LabelToIntegrationPointNumber ( std::string label)
133{
134 int int_pt_number;
135
136 size_t pos = label.find("ipt");
137 NIMBLE_ASSERT(pos == 0,
138 "\nError: LabelToIntegratinPointNumber() called with a label that "
139 "does not beging with ipt.\n");
140
141 // remove "ipt"
142 std::string temp = label.substr(3);
143
144 std::stringstream ss;
145 bool first_digits = true;
146 for (char& c : temp) {
147 if (first_digits && isdigit(c)) {
148 ss << c;
149 } else {
150 first_digits = false;
151 }
152 }
153 ss >> int_pt_number;
154
155 return int_pt_number;
156}
#define NIMBLE_ASSERT(...)
Definition nimble_macros.h:85

◆ LabelToLength()

Length nimble::LabelToLength ( std::string label,
std::map< int, Field > const & data_fields,
int dim )
270{
271 label = RemoveIntegrationPointPrefix(label);
272 for (auto const& it : data_fields) {
273 Field const& field = it.second;
274 if (label == RemoveIntegrationPointPrefix(field.label_)) { return field.length_; }
275 }
276 throw std::invalid_argument("\nError in LabelToLength(), failed to find label " + label + ".\n");
277}
Definition nimble_data_utils.h:124
Length length_
Definition nimble_data_utils.h:142
std::string label_
Definition nimble_data_utils.h:140

◆ LengthToInt()

int nimble::LengthToInt ( Length length,
int dim )
58{
59 int value;
60 if (dim == 2) {
61 switch (length) {
62 case SCALAR: value = 1; break;
63 case VECTOR: value = 2; break;
64 case SYMMETRIC_TENSOR: value = 3; break;
65 case FULL_TENSOR: value = 4; break;
66 case UNDEFINED_LENGTH: throw std::invalid_argument("\nError in LengthToInt(), unrecognized Length.\n");
67 default: value = static_cast<int>(length); break;
68 }
69 } else if (dim == 3) {
70 switch (length) {
71 case SCALAR: value = 1; break;
72 case VECTOR: value = 3; break;
73 case SYMMETRIC_TENSOR: value = 6; break;
74 case FULL_TENSOR: value = 9; break;
75 case UNDEFINED_LENGTH: throw std::invalid_argument("\nError in LengthToInt(), unrecognized Length.\n");
76 default: value = static_cast<int>(length); break;
77 }
78 } else {
79 throw std::invalid_argument("\nError in LengthToInt(), unrecognized dimension.\n");
80 }
81 return value;
82}

◆ LU_Decompose()

void nimble::LU_Decompose ( int num_entries,
MatrixContainer & mat,
int * index )

◆ LU_Solve()

void nimble::LU_Solve ( int num_entries,
MatrixContainer & mat,
double * vec,
int * index )

◆ LU_SolveSystem()

void nimble::LU_SolveSystem ( int num_entries,
MatrixContainer & mat,
double * vec,
int * scratch )

◆ ModelData::EmplaceBlocks< nimble::Block >()

template void nimble::ModelData::EmplaceBlocks< nimble::Block > ( nimble::DataManager & data_manager,
const std::shared_ptr< nimble::MaterialFactoryBase > & material_factory_base )

◆ NimbleVersion()

std::string nimble::NimbleVersion ( )
inline
69{
70 return (NIMBLE_VERSION_STRING);
71}
#define NIMBLE_VERSION_STRING
Definition nimble_version.h:64

◆ operator*()

template<std::size_t N>
details::AXPYResult< N > nimble::operator* ( double alpha,
const nimble::Viewify< N > & A )
219{
220 return {A, alpha};
221}

◆ PackIDSpace()

std::vector< int > nimble::PackIDSpace ( const std::vector< int > & raw_node_ids,
int max_nodes_assigned_to_a_rank,
const mpicontext & context )

◆ ParseContactCommand()

void nimble::ParseContactCommand ( std::string const & command,
std::vector< std::string > & primary_block_names,
std::vector< std::string > & secondary_block_names,
double & penalty_parameter )
101{
102 std::string contact_primary_key;
103 std::string contact_secondary_key;
104
105 std::stringstream ss(command);
106
107 ss >> contact_primary_key;
108 if ((contact_primary_key != "primary_blocks") && (contact_primary_key != "master_blocks")) {
109 std::stringstream error_ss;
110 error_ss << "\n**** Error processing contact command, unknown key: " << contact_primary_key << std::endl;
111 throw std::invalid_argument(error_ss.str());
112 }
113
114 bool secondary_key_found = false;
115 while (ss.good() && !secondary_key_found) {
116 std::string temp;
117 ss >> temp;
118 if ((temp == "secondary_blocks") || (temp == "slave_blocks")) {
119 secondary_key_found = true;
120 } else {
121 primary_block_names.push_back(temp);
122 }
123 }
124
125 if (!secondary_key_found) {
126 throw std::invalid_argument(
127 "\n**** Error processing contact command, expected "
128 "\"secondary_blocks\" or \"slave_blocks\" (deprectated).\n");
129 }
130
131 bool penalty_parameter_key_found = false;
132 while (ss.good() && !penalty_parameter_key_found) {
133 std::string temp;
134 ss >> temp;
135 if (temp == "penalty_parameter") {
136 penalty_parameter_key_found = true;
137 } else {
138 secondary_block_names.push_back(temp);
139 }
140 }
141
142 if (!penalty_parameter_key_found) {
143 throw std::invalid_argument(
144 "\n**** Error processing contact command, expected "
145 "\"penalty_parameter\".\n");
146 }
147
148 ss >> penalty_parameter;
149}

◆ PointEdgeClosestPointFindDistanceSquared()

NIMBLE_INLINE_FUNCTION double nimble::PointEdgeClosestPointFindDistanceSquared ( double const p1[],
double const p2[],
double const p[],
double t )
101{
102 double temp1 = p1[0] + (p2[0] - p1[0]) * t - p[0];
103 double temp2 = p1[1] + (p2[1] - p1[1]) * t - p[1];
104 double temp3 = p1[2] + (p2[2] - p1[2]) * t - p[2];
105 return (temp1 * temp1 + temp2 * temp2 + temp3 * temp3);
106}

◆ PointEdgeClosestPointFindT()

NIMBLE_INLINE_FUNCTION double nimble::PointEdgeClosestPointFindT ( double const p1[],
double const p2[],
double const p[] )
93{
94 return ((p[0] - p1[0]) * (p2[0] - p1[0]) + (p[1] - p1[1]) * (p2[1] - p1[1]) + (p[2] - p1[2]) * (p2[2] - p1[2])) /
95 ((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]) + (p2[2] - p1[2]) * (p2[2] - p1[2]));
96}

◆ PopulateDiagonalPreconditioner()

void nimble::PopulateDiagonalPreconditioner ( const CRSMatrixContainer & A,
CRSMatrixContainer & M )
Parameters
AInput sparse matrix
MDiagonal preconditioner (mathematically M = (diag(A))^{-1})
139{
140 // the preconditioner must be a diagonal matrix
141 if (M.num_rows_ != M.data_.size()) {
142 throw std::invalid_argument(
143 "**** Error in PopulateDiagonalPreconditioner(), preconditioner must "
144 "be a diagonal matrix.\n");
145 }
146
147 int m_index(0);
148 for (int i = 0; i < A.data_.size(); i++) {
149 if (A.i_index_[i] == A.j_index_[i]) { M.data_[m_index++] = 1.0 / A.data_[i]; }
150 }
151}

◆ RemoveIntegrationPointPrefix()

std::string nimble::RemoveIntegrationPointPrefix ( std::string label)
100{
101 std::string stripped_label(label);
102
103 size_t pos = label.find("ipt");
104 if (pos == 0) {
105 // remove "ipt"
106 std::string temp = label.substr(3);
107 // strip off integers, they are the integration point number
108 // the initial value of 1 is for the trailing underscore
109 int num_digits = 1;
110 bool first_digits = true;
111 for (char& c : temp) {
112 if (first_digits && isdigit(c)) {
113 num_digits++;
114 } else {
115 first_digits = false;
116 }
117 }
118 stripped_label = temp.substr(num_digits);
119 }
120 return stripped_label;
121}

◆ SerializeContactFaces()

template<typename ArgT>
void nimble::SerializeContactFaces ( int num_entities,
ArgT contact_entities,
std::vector< char > & buffer )
601{
602 constexpr size_t size_int = sizeof(int);
603 constexpr size_t size_double = sizeof(double);
604 size_t entity_size = 10 * sizeof(double) + 8 * sizeof(int);
605 buffer.resize(entity_size * num_entities);
606 char* scan = &buffer[0];
607 for (int i = 0; i < num_entities; i++) {
608 memcpy(scan, &contact_entities[i].coord_1_x_, size_double);
609 scan += size_double;
610 memcpy(scan, &contact_entities[i].coord_1_y_, size_double);
611 scan += size_double;
612 memcpy(scan, &contact_entities[i].coord_1_z_, size_double);
613 scan += size_double;
614 memcpy(scan, &contact_entities[i].coord_2_x_, size_double);
615 scan += size_double;
616 memcpy(scan, &contact_entities[i].coord_2_y_, size_double);
617 scan += size_double;
618 memcpy(scan, &contact_entities[i].coord_2_z_, size_double);
619 scan += size_double;
620 memcpy(scan, &contact_entities[i].coord_3_x_, size_double);
621 scan += size_double;
622 memcpy(scan, &contact_entities[i].coord_3_y_, size_double);
623 scan += size_double;
624 memcpy(scan, &contact_entities[i].coord_3_z_, size_double);
625 scan += size_double;
626 memcpy(scan, &contact_entities[i].char_len_, size_double);
627 scan += size_double;
628 memcpy(scan, &contact_entities[i].contact_entity_global_id_, size_int);
629 scan += size_int;
630 memcpy(scan, &contact_entities[i].node_id_for_node_1_, size_int);
631 scan += size_int;
632 memcpy(scan, &contact_entities[i].node_id_for_node_2_, size_int);
633 scan += size_int;
634 memcpy(scan, &contact_entities[i].node_id_1_for_fictitious_node_, size_int);
635 scan += size_int;
636 memcpy(scan, &contact_entities[i].node_id_2_for_fictitious_node_, size_int);
637 scan += size_int;
638 memcpy(scan, &contact_entities[i].node_id_3_for_fictitious_node_, size_int);
639 scan += size_int;
640 memcpy(scan, &contact_entities[i].node_id_4_for_fictitious_node_, size_int);
641 scan += size_int;
642 }
643}

◆ split()

std::list< std::string > nimble::split ( std::string line)
65{
66 auto iss = std::istringstream{line};
67 auto str = std::string{};
68 auto items = std::list<std::string>();
69 while (iss >> str) { items.push_back(str); }
70 return items;
71};

◆ string_to_double()

double nimble::string_to_double ( const std::string & s)
inline
91{
92 std::stringstream ss;
93 ss << s;
94 double val = std::numeric_limits<double>::max();
95 ss >> val;
96 return val;
97}

◆ tokenize_string()

std::vector< std::string > nimble::tokenize_string ( const std::string & s)
inline
71{
72 std::vector<std::string> tokens;
73 auto quote_delimited_segments = tokenize_string_with_separator(s, '"');
74 auto is_quoted_segment = [](int i) -> bool { return (i % 2) == 1; };
75 auto quote = quote_delimited_segments.begin();
76 auto quote_end = quote_delimited_segments.end();
77 int i = 0;
78 for (; quote != quote_end; ++quote, ++i) {
79 if (is_quoted_segment(i)) {
80 tokens.push_back(*quote);
81 } else {
82 auto segment_tokens = tokenize_string_with_separator(*quote, ' ');
83 tokens.insert(tokens.end(), segment_tokens.begin(), segment_tokens.end());
84 }
85 }
86 return tokens;
87}

◆ TriangleArea()

NIMBLE_INLINE_FUNCTION double nimble::TriangleArea ( double pt_1_x,
double pt_1_y,
double pt_1_z,
double pt_2_x,
double pt_2_y,
double pt_2_z,
double pt_3_x,
double pt_3_y,
double pt_3_z )
77{
78 double a[3], b[3], cross[3], area;
79 a[0] = pt_2_x - pt_1_x;
80 a[1] = pt_2_y - pt_1_y;
81 a[2] = pt_2_z - pt_1_z;
82 b[0] = pt_3_x - pt_1_x;
83 b[1] = pt_3_y - pt_1_y;
84 b[2] = pt_3_z - pt_1_z;
85 CrossProduct(b, a, cross);
86 area = 0.5 * std::sqrt(cross[0] * cross[0] + cross[1] * cross[1] + cross[2] * cross[2]);
87 return area;
88}
NIMBLE_INLINE_FUNCTION void CrossProduct(const ScalarT *const u, const ScalarT *const v, ScalarT *const result)
Definition nimble_utils.h:395

◆ UnserializeContactFaces()

template<typename ArgT>
void nimble::UnserializeContactFaces ( int num_entities,
ArgT contact_entities,
std::vector< char > & buffer )
648{
649 constexpr size_t size_int = sizeof(int);
650 constexpr size_t size_double = sizeof(double);
651 ContactEntity entity;
653 entity.num_nodes_ = 3;
654 entity.force_1_x_ = 0.0;
655 entity.force_1_y_ = 0.0;
656 entity.force_1_z_ = 0.0;
657 entity.force_2_x_ = 0.0;
658 entity.force_2_y_ = 0.0;
659 entity.force_2_z_ = 0.0;
660 entity.force_3_x_ = 0.0;
661 entity.force_3_y_ = 0.0;
662 entity.force_3_z_ = 0.0;
663 char* scan = &buffer[0];
664 for (int i = 0; i < num_entities; i++) {
665 memcpy(&entity.coord_1_x_, scan, size_double);
666 scan += size_double;
667 memcpy(&entity.coord_1_y_, scan, size_double);
668 scan += size_double;
669 memcpy(&entity.coord_1_z_, scan, size_double);
670 scan += size_double;
671 memcpy(&entity.coord_2_x_, scan, size_double);
672 scan += size_double;
673 memcpy(&entity.coord_2_y_, scan, size_double);
674 scan += size_double;
675 memcpy(&entity.coord_2_z_, scan, size_double);
676 scan += size_double;
677 memcpy(&entity.coord_3_x_, scan, size_double);
678 scan += size_double;
679 memcpy(&entity.coord_3_y_, scan, size_double);
680 scan += size_double;
681 memcpy(&entity.coord_3_z_, scan, size_double);
682 scan += size_double;
683 memcpy(&entity.char_len_, scan, size_double);
684 scan += size_double;
685 memcpy(&entity.contact_entity_global_id_, scan, size_int);
686 scan += size_int;
687 memcpy(&entity.node_id_for_node_1_, scan, size_int);
688 scan += size_int;
689 memcpy(&entity.node_id_for_node_2_, scan, size_int);
690 scan += size_int;
691 memcpy(&entity.node_id_1_for_fictitious_node_, scan, size_int);
692 scan += size_int;
693 memcpy(&entity.node_id_2_for_fictitious_node_, scan, size_int);
694 scan += size_int;
695 memcpy(&entity.node_id_3_for_fictitious_node_, scan, size_int);
696 scan += size_int;
697 memcpy(&entity.node_id_4_for_fictitious_node_, scan, size_int);
698 scan += size_int;
699 entity.SetBoundingBox();
700 contact_entities[i] = entity;
701 }
702}
Definition nimble_contact_entity.h:116
double coord_1_y_
Definition nimble_contact_entity.h:534
double coord_2_z_
Definition nimble_contact_entity.h:538
double force_1_y_
Definition nimble_contact_entity.h:543
int node_id_4_for_fictitious_node_
Definition nimble_contact_entity.h:578
double force_3_y_
Definition nimble_contact_entity.h:549
int node_id_for_node_1_
Definition nimble_contact_entity.h:572
int node_id_for_node_2_
Definition nimble_contact_entity.h:573
double force_3_z_
Definition nimble_contact_entity.h:550
double force_2_x_
Definition nimble_contact_entity.h:545
void SetBoundingBox()
Create a bounding box centered around the entity.
Definition nimble_contact_entity.cc:76
int contact_entity_global_id_
Definition nimble_contact_entity.h:591
double force_1_x_
Definition nimble_contact_entity.h:542
@ TRIANGLE
Definition nimble_contact_entity.h:122
double coord_3_x_
Definition nimble_contact_entity.h:539
double coord_1_x_
Definition nimble_contact_entity.h:533
double coord_3_z_
Definition nimble_contact_entity.h:541
double char_len_
Definition nimble_contact_entity.h:557
double coord_2_x_
Definition nimble_contact_entity.h:536
double force_2_z_
Definition nimble_contact_entity.h:547
double coord_2_y_
Definition nimble_contact_entity.h:537
int node_id_2_for_fictitious_node_
Definition nimble_contact_entity.h:576
double force_1_z_
Definition nimble_contact_entity.h:544
CONTACT_ENTITY_TYPE entity_type_
Definition nimble_contact_entity.h:531
int node_id_1_for_fictitious_node_
Definition nimble_contact_entity.h:575
int node_id_3_for_fictitious_node_
Definition nimble_contact_entity.h:577
double force_3_x_
Definition nimble_contact_entity.h:548
double coord_3_y_
Definition nimble_contact_entity.h:540
double coord_1_z_
Definition nimble_contact_entity.h:535
double force_2_y_
Definition nimble_contact_entity.h:546
int num_nodes_
Definition nimble_contact_entity.h:532

Variable Documentation

◆ MAX_C_STR_SIZE

int nimble::MAX_C_STR_SIZE = 256
constexpr