Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78709322
test_explicit_dynamic.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Aug 22, 13:08
Size
4 KB
Mime Type
text/x-c
Expires
Sat, Aug 24, 13:08 (2 d)
Engine
blob
Format
Raw Data
Handle
20076995
Attached To
rAKA akantu
test_explicit_dynamic.cc
View Options
/* -------------------------------------------------------------------------- */
#include "contact_mechanics_model.hh"
#include "coupler_solid_contact.hh"
#include "non_linear_solver.hh"
#include "solid_mechanics_model.hh"
#include "surface_selector.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
template<typename T>
std::vector<T> arrange(T start, T stop, T step = 1) {
std::vector<T> values;
for (T value = start; value <= stop; value += step)
values.push_back(value);
return values;
}
int main(int argc, char * argv[]) {
UInt max_steps = 2000;
Real max_displacement = 1e-2;
Real damping_ratio = 0.99;
std::string mesh_file = "flat_on_flat.msh";
std::string material_file = "material.dat";
const UInt spatial_dimension = 2;
initialize(material_file, argc, argv);
Mesh mesh(spatial_dimension);
mesh.read(mesh_file);
CouplerSolidContact coupler(mesh);
auto & solid = coupler.getSolidMechanicsModel();
auto & contact = coupler.getContactMechanicsModel();
auto && material_selector =
std::make_shared<MeshDataMaterialSelector<std::string>>("physical_names",
solid);
solid.setMaterialSelector(material_selector);
coupler.initFull(_analysis_method = _explicit_lumped_mass);
auto && surface_selector = std::make_shared<PhysicalSurfaceSelector>(mesh);
contact.getContactDetector().setSurfaceSelector(surface_selector);
solid.applyBC(BC::Dirichlet::FixedValue(0.0, _x), "upper");
solid.applyBC(BC::Dirichlet::FixedValue(0.0, _x), "lower");
Real time_step = solid.getStableTimeStep();
time_step *= 0.05;
coupler.setTimeStep(time_step);
std::cout << "Stable time increment : " << time_step << " sec " << std::endl;
coupler.setBaseName("explicit-dynamic");
coupler.addDumpFieldVector("displacement");
coupler.addDumpFieldVector("normals");
coupler.addDumpFieldVector("contact_force");
coupler.addDumpFieldVector("external_force");
coupler.addDumpFieldVector("internal_force");
coupler.addDumpField("gaps");
coupler.addDumpField("areas");
coupler.addDumpField("blocked_dofs");
coupler.addDumpField("strain");
coupler.addDumpField("stress");
auto & velocity = solid.getVelocity();
auto & gaps = contact.getGaps();
auto xi = arrange<Real>(0, 1, 1./max_steps);
std::vector<Real> displacements;
std::transform(xi.begin(), xi.end(), std::back_inserter(displacements),
[&](Real & p) -> Real {
return 0. + (max_displacement)*pow(p, 3)*(10-15*p+ 6*pow(p,2)); });
for (UInt s : arange(max_steps)) {
solid.applyBC(BC::Dirichlet::FixedValue(-displacements[s], _y), "loading");
solid.applyBC(BC::Dirichlet::FixedValue(displacements[s], _y), "fixed");
coupler.solveStep();
for(auto && tuple : zip(gaps,
make_view(velocity, spatial_dimension))){
auto & gap = std::get<0>(tuple);
auto & vel = std::get<1>(tuple);
if(gap > 0) {
vel *= damping_ratio;
}
}
if (s % 100 == 0) {
coupler.dump();
}
}
coupler.dump();
const ElementType element_type = _quadrangle_4;
const Array<Real> & stress_vect = solid.getMaterial("upper").getStress(element_type);
auto stress_it = stress_vect.begin(spatial_dimension, spatial_dimension);
auto stress_end = stress_vect.end(spatial_dimension, spatial_dimension);
Real stress_tolerance = 1e-2;
Matrix<Real> presc_stress{{0, 0}, {0, 7e5}};
for (; stress_it != stress_end; ++stress_it) {
const auto & stress = *stress_it;
Real stress_error = (std::abs(stress(1, 1)) - presc_stress(1, 1))/(presc_stress(1, 1));
// if error is more than 1%
if (std::abs(stress_error) > stress_tolerance) {
std::cerr << "stress error: " << stress_error << " > " << stress_tolerance
<< std::endl;
std::cerr << "stress: " << stress << std::endl
<< "prescribed stress: " << presc_stress << std::endl;
return EXIT_FAILURE;
}
}
finalize();
return EXIT_SUCCESS;
}
Event Timeline
Log In to Comment