PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
map.cpp
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2026 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#include "map.h"
12#include "util/matrix.h"
13
14void fe::mapToPhysical(std::vector<QuadData> &qds,
15 const std::vector<util::Point> &nodes, bool derivatives) {
16 for (auto &qd : qds) {
17 const auto n = qd.d_shapes.size();
18 if (qd.d_derShapes.size() != n || n == 0 || qd.d_derShapes[0].empty())
19 continue;
20 const int dim = static_cast<int>(qd.d_derShapes[0].size());
21
22 std::vector<std::vector<double>> J(dim, std::vector<double>(dim, 0.));
23 for (int a = 0; a < static_cast<int>(n); a++)
24 for (int alpha = 0; alpha < dim; alpha++)
25 for (int j = 0; j < dim; j++)
26 J[alpha][j] += qd.d_derShapes[a][alpha] * nodes[a][j];
27
28 qd.d_J = J;
29 qd.d_detJ = util::det(J);
30 qd.d_w *= qd.d_detJ;
31
32 qd.d_p = util::Point();
33 for (size_t a = 0; a < n; a++)
34 for (int j = 0; j < dim; j++)
35 qd.d_p[j] += qd.d_shapes[a] * nodes[a][j];
36
37 if (!derivatives)
38 continue;
39
40 const auto Jinv = util::inv(J);
41 for (size_t a = 0; a < n; a++)
42 qd.d_derShapes[a] = util::dot(Jinv, qd.d_derShapes[a]);
43 }
44}
void mapToPhysical(std::vector< QuadData > &qds, const std::vector< util::Point > &nodes, bool derivatives)
Definition map.cpp:14
double det(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
Definition matrix.cpp:75
std::vector< std::vector< double > > inv(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
Definition matrix.cpp:93
std::vector< double > dot(const std::vector< std::vector< double > > &m, const std::vector< double > &v)
Computes the dot product between matrix and vector.
Definition matrix.cpp:38
A structure to represent 3d vectors.
Definition point.h:30