Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F77938721
cohesive_extrinsic_IG_TG.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
Sat, Aug 17, 08:32
Size
6 KB
Mime Type
text/x-c++
Expires
Mon, Aug 19, 08:32 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
19928052
Attached To
rAKA akantu
cohesive_extrinsic_IG_TG.cc
View Options
/**
* @file cohesive_extrinsic_IG_TG.cc
*
* @author Seyedeh Mohadeseh Taheri Mousavi <mohadeseh.taherimousavi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 21 2013
* @date last modification: Thu Jun 05 2014
*
* @brief Test for considering different cohesive properties for intergranular (IG) and
* transgranular (TG) fractures in extrinsic cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu 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 Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <limits>
#include <fstream>
#include <iostream>
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
class MultiGrainMaterialSelector : public DefaultMaterialCohesiveSelector {
public:
MultiGrainMaterialSelector(const SolidMechanicsModelCohesive & model, const ID & transgranular_id, const ID & intergranular_id) :
DefaultMaterialCohesiveSelector(model),
transgranular_id(transgranular_id),
intergranular_id(intergranular_id),
model(model),
mesh(model.getMesh()),
mesh_facets(model.getMeshFacets()),
spatial_dimension(model.getSpatialDimension()),
nb_IG(0), nb_TG(0) {
}
UInt operator()(const Element & element) {
if(mesh_facets.getSpatialDimension(element.type) == (spatial_dimension - 1)) {
const std::vector<Element> & element_to_subelement = mesh_facets.getElementToSubelement(element.type, element.ghost_type)(element.element);
const Element & el1 = element_to_subelement[0];
const Element & el2 = element_to_subelement[1];
UInt grain_id1 = mesh.getData<UInt>("tag_0", el1.type, el1.ghost_type)(el1.element);
if(el2 != ElementNull) {
UInt grain_id2 = mesh.getData<UInt>("tag_0", el2.type, el2.ghost_type)(el2.element);
if (grain_id1 == grain_id2){
//transgranular = 0 indicator
nb_TG++;
return model.getMaterialIndex(transgranular_id);
} else {
//intergranular = 1 indicator
nb_IG++;
return model.getMaterialIndex(intergranular_id);
}
} else {
//transgranular = 0 indicator
nb_TG++;
return model.getMaterialIndex(transgranular_id);
}
} else {
return DefaultMaterialCohesiveSelector::operator()(element);
}
}
private:
ID transgranular_id, intergranular_id;
const SolidMechanicsModelCohesive & model;
const Mesh & mesh;
const Mesh & mesh_facets;
UInt spatial_dimension;
UInt nb_IG;
UInt nb_TG;
};
/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[]) {
initialize("material.dat", argc, argv);
const UInt spatial_dimension = 2;
const UInt max_steps = 1000;
Mesh mesh(spatial_dimension);
mesh.read("square.msh");
SolidMechanicsModelCohesive model(mesh);
/// model initialization
MultiGrainMaterialSelector material_selector(model, "TG_cohesive", "IG_cohesive");
model.setMaterialSelector(material_selector);
model.initFull(SolidMechanicsModelCohesiveOptions(_explicit_lumped_mass, true, false));
Real time_step = model.getStableTimeStep()*0.05;
model.setTimeStep(time_step);
std::cout << "Time step: " << time_step << std::endl;
model.assembleMassLumped();
Array<Real> & position = mesh.getNodes();
Array<Real> & velocity = model.getVelocity();
Array<bool> & boundary = model.getBlockedDOFs();
Array<Real> & displacement = model.getDisplacement();
UInt nb_nodes = mesh.getNbNodes();
/// boundary conditions
for (UInt n = 0; n < nb_nodes; ++n) {
if (position(n, 1) > 0.99|| position(n, 1) < -0.99)
boundary(n, 1) = true;
if (position(n, 0) > 0.99 || position(n, 0) < -0.99)
boundary(n, 0) = true;
}
model.updateResidual();
model.setBaseName("extrinsic");
model.addDumpFieldVector("displacement");
model.addDumpField("velocity" );
model.addDumpField("acceleration");
model.addDumpField("residual" );
model.addDumpField("stress");
model.addDumpField("grad_u");
model.dump();
/// initial conditions
Real loading_rate = 0.1;
// bar_height = 2
Real VI = loading_rate * 2* 0.5;
for (UInt n = 0; n < nb_nodes; ++n) {
velocity(n, 1) = loading_rate * position(n, 1);
velocity(n, 0) = loading_rate * position(n, 0);
}
model.dump();
Real dispy = 0;
/// Main loop
for (UInt s = 1; s <= max_steps; ++s) {
dispy += VI * time_step;
/// update displacement on extreme nodes
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (position(n, 1) > 0.99){
displacement(n, 1) = dispy;
velocity(n,1) = VI;}
if (position(n, 1) < -0.99){
displacement(n, 1) = -dispy;
velocity(n,1) = -VI;}
if (position(n, 0) > 0.99){
displacement(n, 0) = dispy;
velocity(n,0) = VI;}
if (position(n, 0) < -0.99){
displacement(n, 0) = -dispy;
velocity(n,0) = -VI;}
}
model.checkCohesiveStress();
model.explicitPred();
model.updateResidual();
model.updateAcceleration();
model.explicitCorr();
model.dump();
if(s % 10 == 0) {
std::cout << "passing step " << s << "/" << max_steps << std::endl;
}
}
Real Ed = model.getEnergy("dissipated");
Real Edt = 40;
std::cout << Ed << " " << Edt << std::endl;
if (Ed < Edt * 0.999 || Ed > Edt * 1.001 || std::isnan(Ed)) {
std::cout << "The dissipated energy is incorrect" << std::endl;
finalize();
return EXIT_FAILURE;
}
finalize();
std::cout << "OK: test_cohesive_extrinsic_IG_TG was passed!" << std::endl;
return EXIT_SUCCESS;
}
Event Timeline
Log In to Comment