Commit 076a7849 authored by Guido Giuntoli's avatar Guido Giuntoli

Adding material benchmarks: elastic, plastic and damage

parent edb104d4
......@@ -26,6 +26,9 @@ set(testsources
benchmark-mic-2.cpp
benchmark-mic-3.cpp
benchmark-mic-4.cpp
benchmark-elastic.cpp
benchmark-plastic.cpp
benchmark-damage.cpp
)
# Iterate over the list above
......@@ -50,6 +53,9 @@ add_test(NAME test_ell_2 COMMAND test_ell_2)
add_test(NAME test_ell_mvp_openacc COMMAND test_ell_mvp_openacc 5 5)
add_test(NAME test_util_1 COMMAND test_util_1)
add_test(NAME test_material COMMAND test_material 5)
add_test(NAME benchmark-elastic COMMAND benchmark-elastic)
add_test(NAME benchmark-plastic COMMAND benchmark-plastic)
add_test(NAME benchmark-damage COMMAND benchmark-damage)
add_test(NAME test_damage COMMAND test_damage 10)
set_property(TARGET test3d_3 PROPERTY LINKER_LANGUAGE Fortran)
/*
* This is a test example for MicroPP: a finite element library
* to solve microstructural problems for composite materials.
*
* Copyright (C) - 2018 - Jimmy Aguilar Mena <kratsbinovish@gmail.com>
* Guido Giuntoli <gagiuntoli@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <chrono>
#include <bits/stdc++.h>
#include "micro.hpp"
using namespace std;
using namespace std::chrono;
const int time_steps = 10;
const double sig_sol[time_steps][6] = {
{ 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.0, 0.0, 0.0 },
{ 5.40000000000000e+04, 1.80000000000000e+04, 1.80000000000000e+04, 0.0, 0.0, 0.0 },
{ 1.08000000000000e+05, 3.60000000000000e+04, 3.60000000000000e+04, 0.0, 0.0, 0.0 },
{ 6.34099396490701e+05, 2.11366465496900e+05, 2.11366465496900e+05, 0.0, 0.0, 0.0 },
{ 1.13477225575052e+06, 3.78257418583506e+05, 3.78257418583506e+05, 0.0, 0.0, 0.0 },
{ 1.40477225575052e+06, 4.68257418583505e+05, 4.68257418583505e+05, 0.0, 0.0, 0.0 },
{ 1.67477225575052e+06, 5.58257418583506e+05, 5.58257418583506e+05, 0.0, 0.0, 0.0 },
{ 1.94477225575052e+06, 6.48257418583506e+05, 6.48257418583506e+05, 0.0, 0.0, 0.0 },
{ 2.21477225575052e+06, 7.38257418583506e+05, 7.38257418583506e+05, 0.0, 0.0, 0.0 },
{ 2.48477225575052e+06, 8.28257418583506e+05, 8.28257418583506e+05, 0.0, 0.0, 0.0 }
};
double eps_vs_t(double time, double t_final) {
const double eps_max = 1.0e-1;
double eps = eps_max * time;
return eps;
}
int main(int argc, char **argv)
{
const int ngp = 1;
const int n = 2;
const int dir = 0;
const double t_final = 0.15;
const double dt = t_final / time_steps;
double time = 0.0;
micropp_params_t mic_params;
mic_params.ngp = ngp;
mic_params.size[0] = n;
mic_params.size[1] = n;
mic_params.size[2] = n;
mic_params.type = MIC_HOMOGENEOUS;
material_set(&mic_params.materials[0], 2, 3.0e7, 0.25, 0.0, 0.0, 1.0e5);
material_set(&mic_params.materials[1], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[2], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
mic_params.lin_stress = false;
micropp<3> micro(mic_params);
micro.print_info();
ofstream file;
file.open("result.dat");
file.precision(14);
file << scientific;
auto start = high_resolution_clock::now();
double sig[6];
double eps[6] = { 0. };
cout << scientific;
for (int t = 0; t < time_steps; ++t) {
cout << "Time step = " << t << endl;
eps[dir] = eps_vs_t(time, t_final);
micro.set_strain(0, eps);
cout << "eps = ";
for (int i = 0; i < 6; ++i) {
cout << eps[i] << " ";
}
cout << endl;
cout << "Homogenizing ..." << endl;
micro.homogenize();
cout << "sig = ";
micro.get_stress(0, sig);
for (int i = 0; i < 6; ++i) {
assert(fabs(sig_sol[t][i] - sig[i]) < 1.0e-8);
cout << sig[i] << "\t";
}
cout << endl;
micro.update_vars();
for (int i = 0; i < 6; ++i) {
file << eps[i] << "\t";
}
for (int i = 0; i < 6; ++i) {
file << sig[i] << "\t";
}
file << endl;
time += dt;
}
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
cout << "time = " << duration.count() << " ms" << endl;
return 0;
}
/*
* This is a test example for MicroPP: a finite element library
* to solve microstructural problems for composite materials.
*
* Copyright (C) - 2018 - Jimmy Aguilar Mena <kratsbinovish@gmail.com>
* Guido Giuntoli <gagiuntoli@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <chrono>
#include <bits/stdc++.h>
#include "micro.hpp"
using namespace std;
using namespace std::chrono;
const int time_steps = 10;
const double sig_sol[time_steps][6] = {
{ 0.00e0, 0.00e0, 0.00e0, 0.0, 0.0, 0.0 },
{ 5.40e4, 1.80e4, 1.80e4, 0.0, 0.0, 0.0 },
{ 1.08e5, 3.60e4, 3.60e4, 0.0, 0.0, 0.0 },
{ 1.62e5, 5.40e4, 5.40e4, 0.0, 0.0, 0.0 },
{ 2.16e5, 7.20e4, 7.20e4, 0.0, 0.0, 0.0 },
{ 2.70e5, 9.00e4, 9.00e4, 0.0, 0.0, 0.0 },
{ 3.24e5, 1.08e5, 1.08e5, 0.0, 0.0, 0.0 },
{ 3.78e5, 1.26e5, 1.26e5, 0.0, 0.0, 0.0 },
{ 4.32e5, 1.44e5, 1.44e5, 0.0, 0.0, 0.0 },
{ 4.86e5, 1.62e5, 1.62e5, 0.0, 0.0, 0.0 }
};
double eps_vs_t(double time, double t_final) {
const double eps_max = 1.0e-1;
double eps = eps_max * time;
return eps;
}
int main(int argc, char **argv)
{
const int ngp = 1;
const int n = 2;
const int dir = 0;
const double t_final = 0.15;
const double dt = t_final / time_steps;
double time = 0.0;
micropp_params_t mic_params;
mic_params.ngp = ngp;
mic_params.size[0] = n;
mic_params.size[1] = n;
mic_params.size[2] = n;
mic_params.type = MIC_HOMOGENEOUS;
material_set(&mic_params.materials[0], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[1], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[2], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
mic_params.lin_stress = false;
micropp<3> micro(mic_params);
micro.print_info();
ofstream file;
file.open("result.dat");
file << scientific;
auto start = high_resolution_clock::now();
double sig[6];
double eps[6] = { 0. };
cout << scientific;
for (int t = 0; t < time_steps; ++t) {
cout << "Time step = " << t << endl;
eps[dir] = eps_vs_t(time, t_final);
micro.set_strain(0, eps);
cout << "eps = ";
for (int i = 0; i < 6; ++i) {
cout << eps[i] << " ";
}
cout << endl;
cout << "Homogenizing ..." << endl;
micro.homogenize();
cout << "sig = ";
micro.get_stress(0, sig);
for (int i = 0; i < 6; ++i) {
assert(fabs(sig_sol[t][i] - sig[i]) < 1.0e-10);
cout << sig[i] << "\t";
}
cout << endl;
micro.update_vars();
for (int i = 0; i < 6; ++i) {
file << eps[i] << "\t";
}
for (int i = 0; i < 6; ++i) {
file << sig[i] << "\t";
}
file << endl;
time += dt;
}
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
cout << "time = " << duration.count() << " ms" << endl;
return 0;
}
......@@ -71,15 +71,16 @@ int main(int argc, char **argv)
mic_params.size[1] = n;
mic_params.size[2] = n;
mic_params.type = MIC3D_SPHERES;
mic_params.geo_params[0] = 0.1;
mic_params.geo_params[1] = 0.02;
mic_params.geo_params[2] = 0.01;
mic_params.geo_params[0] = 0.0;
mic_params.geo_params[1] = 0.0;
mic_params.geo_params[2] = 0.0;
mic_params.geo_params[4] = 0.0;
//mic_params.subiterations = true;
//mic_params.nsubiterations = 10;
mic_params.nr_max_its = 12;
material_set(&mic_params.materials[0], 2, 1.0e7, 0.3, 0.0, 0.0, 1.0e5);
material_set(&mic_params.materials[1], 0, 3.0e7, 0.3, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[2], 0, 3.0e7, 0.3, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[0], 1, 3.0e7, 0.3, 1.0e7, 1.0e7, 0.0);
material_set(&mic_params.materials[1], 0, 3.0e3, 0.3, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[2], 0, 3.0e7, 0.3, 0.0, 0.0, 0.0);
mic_params.mpi_rank = 0;
mic_params.calc_ctan_lin = false;
mic_params.lin_stress = false;
......
......@@ -79,8 +79,9 @@ int main(int argc, char **argv)
mic_params.size[2] = n;
mic_params.type = micro_type;
mic_params.geo_params[0] = 0.1;
mic_params.geo_params[1] = 0.02;
mic_params.geo_params[2] = 0.01;
mic_params.geo_params[1] = 0.0;
mic_params.geo_params[2] = 0.0;
mic_params.geo_params[3] = 0.0;
material_set(&mic_params.materials[0], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[1], 0, 3.0e8, 0.25, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[2], 0, 3.0e7, 0.3, 0.0, 0.0, 0.0);
......
/*
* This is a test example for MicroPP: a finite element library
* to solve microstructural problems for composite materials.
*
* Copyright (C) - 2018 - Jimmy Aguilar Mena <kratsbinovish@gmail.com>
* Guido Giuntoli <gagiuntoli@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <chrono>
#include <bits/stdc++.h>
#include "micro.hpp"
using namespace std;
using namespace std::chrono;
const int time_steps = 10;
const double sig_sol[time_steps][6] = {
{ 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00, 0.0, 0.0, 0.0 },
{ 5.40000000000000e+04, 1.80000000000000e+04, 1.80000000000000e+04, 0.0, 0.0, 0.0 },
{ 1.08000000000000e+05, 3.60000000000000e+04, 3.60000000000000e+04, 0.0, 0.0, 0.0 },
{ 1.57826086961140e+05, 5.60869565194300e+04, 5.60869565194300e+04, 0.0, 0.0, 0.0 },
{ 1.93043478265488e+05, 8.34782608672561e+04, 8.34782608672561e+04, 0.0, 0.0, 0.0 },
{ 2.28260869570719e+05, 1.10869565214640e+05, 1.10869565214640e+05, 0.0, 0.0, 0.0 },
{ 2.63478260875790e+05, 1.38260869562105e+05, 1.38260869562105e+05, 0.0, 0.0, 0.0 },
{ 2.98695652180861e+05, 1.65652173909570e+05, 1.65652173909570e+05, 0.0, 0.0, 0.0 },
{ 3.33913043485931e+05, 1.93043478257034e+05, 1.93043478257034e+05, 0.0, 0.0, 0.0 },
{ 3.69130434791002e+05, 2.20434782604499e+05, 2.20434782604499e+05, 0.0, 0.0, 0.0 }
};
double eps_vs_t(double time, double t_final) {
const double eps_max = 1.0e-1;
double eps = eps_max * time;
return eps;
}
int main(int argc, char **argv)
{
const int ngp = 1;
const int n = 2;
const int dir = 0;
const double t_final = 0.15;
const double dt = t_final / time_steps;
double time = 0.0;
micropp_params_t mic_params;
mic_params.ngp = ngp;
mic_params.size[0] = n;
mic_params.size[1] = n;
mic_params.size[2] = n;
mic_params.type = MIC_HOMOGENEOUS;
material_set(&mic_params.materials[0], 1, 3.0e7, 0.25, 1.0e7, 1.0e5, 0.0);
material_set(&mic_params.materials[1], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
material_set(&mic_params.materials[2], 0, 3.0e7, 0.25, 0.0, 0.0, 0.0);
mic_params.lin_stress = false;
micropp<3> micro(mic_params);
micro.print_info();
ofstream file;
file.open("result.dat");
file.precision(14);
file << scientific;
auto start = high_resolution_clock::now();
double sig[6];
double eps[6] = { 0. };
cout << scientific;
for (int t = 0; t < time_steps; ++t) {
cout << "Time step = " << t << endl;
eps[dir] = eps_vs_t(time, t_final);
micro.set_strain(0, eps);
cout << "eps = ";
for (int i = 0; i < 6; ++i) {
cout << eps[i] << " ";
}
cout << endl;
cout << "Homogenizing ..." << endl;
micro.homogenize();
cout << "sig = ";
micro.get_stress(0, sig);
for (int i = 0; i < 6; ++i) {
assert(fabs(sig_sol[t][i] - sig[i]) < 1.0e-8);
cout << sig[i] << "\t";
}
cout << endl;
micro.update_vars();
for (int i = 0; i < 6; ++i) {
file << eps[i] << "\t";
}
for (int i = 0; i < 6; ++i) {
file << sig[i] << "\t";
}
file << endl;
time += dt;
}
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
cout << "time = " << duration.count() << " ms" << endl;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment