-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💻🔧 Return nodal property with Eigen::Map and change the type of its m…
…ethods from boolean to void
- Loading branch information
1 parent
6f2f14a
commit c2e1c70
Showing
3 changed files
with
24 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
#include "nodal_properties.h" | ||
|
||
// Function to create new property with given name and size (rows x cols) | ||
bool mpm::NodalProperties::create_property(const std::string& property, | ||
void mpm::NodalProperties::create_property(const std::string& property, | ||
unsigned rows, unsigned columns) { | ||
// Initialize a matrix with size of rows times columns and insert it to the | ||
// property database map | ||
Eigen::MatrixXd property_data = Eigen::MatrixXd::Zero(rows, columns); | ||
properties_.insert( | ||
std::pair<std::string, Eigen::MatrixXd>(property, property_data)); | ||
return true; | ||
} | ||
|
||
// Return data in the nodal properties map at a specific index | ||
Eigen::MatrixXd mpm::NodalProperties::property(const std::string& property, | ||
unsigned node_id, | ||
unsigned mat_id, | ||
unsigned nprops = 1) const { | ||
return properties_.at(property).block(node_id * nprops, mat_id, nprops, 1); | ||
unsigned nprops) const { | ||
double* position = &properties_.at(property)(node_id * nprops, mat_id); | ||
mpm::MapProperty property_map(position, nprops); | ||
return property_map; | ||
} | ||
|
||
// Assign property value to a pair of node and material | ||
bool mpm::NodalProperties::assign_property(const std::string& property, | ||
void mpm::NodalProperties::assign_property(const std::string& property, | ||
unsigned node_id, unsigned mat_id, | ||
Eigen::MatrixXd property_value, | ||
unsigned nprops = 1) { | ||
unsigned nprops) { | ||
properties_.at(property).block(node_id * nprops, mat_id, nprops, 1) = | ||
property_value; | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters