MPM-Geomechanics
Material Point Method for simulating geo-materials under large deformation conditions
Loading...
Searching...
No Matches
Cell.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2021-2025 MPM-Geomechanics Development Team
3
4#ifndef CELL_H_
5#define CELL_H_
6
7#include <vector>
8
9#include <Eigen/Eigenvalues>
10using namespace Eigen;
11
12#include "Node.h"
13
14class Cell {
15
16 public:
17
18 Cell() : volume(0.0), id(0) {}
19
21
22 if (nodes.size() != 8) {
23 volume = 0.0;
24 return;
25 }
26
27 // base vectors of the parallelepiped
28 Vector3d v1 = nodes[1]->getCoordinates() - nodes[0]->getCoordinates(); // X direction
29 Vector3d v2 = nodes[2]->getCoordinates() - nodes[0]->getCoordinates(); // Y direction
30 Vector3d v3 = nodes[4]->getCoordinates() - nodes[0]->getCoordinates(); // Z direction
31
32 // cross product of two base vectors
33 volume = std::abs(v1.cross(v2).dot(v3));
34
35 // set id of the cell with the id of the first node
36 this->id = nodes[0]->getId();
37 }
38
39 inline double getVolume() const { return volume; };
40 inline int getId() const { return id; };
41 inline std::vector<Node*> getNodes() const { return nodes; };
42 inline void setNodes(const std::vector<Node*>& nodes) { this->nodes = nodes; };
43
44 private:
45 std::vector<Node*> nodes;
46 double volume;
47 int id;
48};
49
50#endif /* CELL_H_ */
Definition Cell.h:14
double getVolume() const
Definition Cell.h:39
int id
Definition Cell.h:47
Cell()
Definition Cell.h:18
double volume
Definition Cell.h:46
std::vector< Node * > nodes
Definition Cell.h:45
void setNodes(const std::vector< Node * > &nodes)
Definition Cell.h:42
void computeVolume()
Definition Cell.h:20
int getId() const
Definition Cell.h:40
std::vector< Node * > getNodes() const
Definition Cell.h:41