micromechanical (C++)
Loading...
Searching...
No Matches
plugins Directory Reference

Detailed Description

Prerequisites

First, you need to install the micromechanical Python package for the micromechanical command to be available. To do so, run the following command in the root directory of the micromechanical project:

pip install .[cli]

Install cmake and one of the following C/C++ compilers:

Then, use the micromechanical plugin make command to compile the plugins:

micromechanical plugin make elastic.cpp changhicher.cpp --working_directory=plugin --build=build

This will compile the elastic.cpp and changhicher.cpp plugins to dynamic libraries in the plugin directory using cmake as the build system. Type micromechanical plugin make --help for more information about the command. After compiling the plugins, you can use the built plugins in your micromechanical simulations:

#include <map>
#include <string>
using namespace micromechanical;
using namespace micromechanical::contacts;
std::map<std::string, double> props = {{"kt0", 32.0}, {"R", 2.5}};
auto *contact = ContactLawRegistry<double>::create("elastic.dll", props);
auto *model = MicromechanicalRegistry<double>::create("changhicher.dll", ContactLawType::Elastic, props);
Manager for contact laws.
Manager for micromechanical models.
Definition contacts.hpp:27
@ Elastic
elastic contact law
Definition contacts.hpp:32
helper functions for mathematical operations
Definition changhicher.hpp:16
static MicromechanicalBase< T > * create(MicromechanicalBase< T > *model, ContactLawType contact, const std::map< std::string, T > &props={}, T npv=1e9, T radius=0.65e-3)
Create a micromechanical model.
Definition models.hpp:68
static ContactLawBase< T > * create(ContactLawBase< T > *contact, const std::map< std::string, T > &props={})
Create contact law.
Definition contacts.hpp:54

Create plugins for micromechanical models

A plugin for a micromechanical model is a .cpp file that contains a function named micromechanical_model that returns a pointer to a MicromechanicalBase object. The function must have the following signature:

using namespace micromechanical::core;
extern "C" MicromechanicalBase<double>* micromechanical_model(ContactLawBase<double>* contact,
const std::map<std::string, double>& props = {},
double npv = 1e9,
double radius = 0.65e-3) {
// Define the micromechanical model
}
Base class for micromechanical models.
Definition average.hpp:12
Base class for contact laws.
Definition contactlaw.hpp:22
Base class for micromechanical models.
Definition micromechanical.hpp:28

Create plugins for contact laws

A plugin for a contact law is a .cpp file that contains a function named micromechanical_contact that returns a pointer to a ContactLawBase object. The function must have the following signature:

#include <map>
#include <string>
using namespace micromechanical::core;
extern "C" ContactLawBase<double>* micromechanical_contact(const std::map<std::string, double>& props) {
// Define the contact law
}
Base class for contact laws.