Page MenuHomec4science

No OneTemporary

File Metadata

Created
Sat, Nov 23, 23:09
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/extra_packages/traction-at-split-node-contact/README.txt b/extra_packages/traction-at-split-node-contact/README.txt
index 8383d544d..b38a0de4b 100644
--- a/extra_packages/traction-at-split-node-contact/README.txt
+++ b/extra_packages/traction-at-split-node-contact/README.txt
@@ -1,19 +1,26 @@
#===============================================================================
# @file README.txt
#
#
+# @date creation: Tue Dec 02 2014
+# @date last modification: Mon Feb 01 2016
#
-# @brief
+# @brief kammer
#
# @section LICENSE
#
-# Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-2018 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/>.
#
#===============================================================================
Short explanation for AkantuSimTools:
Using ccmake for compilation, give the path to the build folder of akantu. By putting build_shared_libs on, the library is dynamic. Give a cmake_install_prefix (e.g., ./install).
When compiling use: make install (don't forget to create the folder in which you install)
diff --git a/extra_packages/traction-at-split-node-contact/package.cmake b/extra_packages/traction-at-split-node-contact/package.cmake
index 5be450a70..401cd0ad2 100644
--- a/extra_packages/traction-at-split-node-contact/package.cmake
+++ b/extra_packages/traction-at-split-node-contact/package.cmake
@@ -1,79 +1,92 @@
#===============================================================================
# @file package.cmake
#
+# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
+# @date creation: Tue Dec 02 2014
+# @date last modification: Wed Feb 03 2016
#
-# @brief
+# @brief
#
# @section LICENSE
#
-# Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+# Copyright (©) 2015-2018 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/>.
+#
#===============================================================================
-
-package_declare(traction-at-split-node-contact
+package_declare(traction_at_split_node_contact
DESCRIPTION "The super contact of David"
DEPENDS iohelper)
-package_declare_sources(traction-at-split-node-contact
+package_declare_sources(traction_at_split_node_contact
common/synchronized_array.cc
common/parameter_reader.cc
common/manual_restart.cc
functions/boundary_functions.cc
ntn_contact/ntn_base_contact.cc
ntn_contact/ntn_contact.cc
ntn_contact/ntrf_contact.cc
ntn_contact/mIIasym_contact.cc
ntn_contact/ntn_base_friction.cc
ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc
ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc
ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc
ntn_contact/ntn_initiation_function.cc
tasn_contact.hh
# headers
common/synchronized_array.hh
common/parameter_reader.hh
common/manual_restart.hh
functions/boundary_functions.hh
functions/node_filter.hh
boundary_conditions/force_based_dirichlet.hh
boundary_conditions/spring_bc.hh
boundary_conditions/inclined_flat_dirichlet.hh
ntn_contact/ntn_base_contact.hh
ntn_contact/ntn_contact.hh
ntn_contact/ntrf_contact.hh
ntn_contact/mIIasym_contact.hh
ntn_contact/ntn_base_friction.hh
ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh
ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh
ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh
ntn_contact/friction_laws/ntn_friclaw_coulomb.hh
ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh
ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh
ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh
ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing.hh
ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh
ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh
ntn_contact/ntn_friction.hh
ntn_contact/ntn_friction_tmpl.hh
ntn_contact/ntrf_friction.hh
ntn_contact/ntrf_friction_tmpl.hh
ntn_contact/ntn_initiation_function.hh
# inlines
common/synchronized_array_inline_impl.cc
ntn_contact/ntn_base_contact_inline_impl.cc
)
-
-
diff --git a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh
index b2b4214fa..e57d1a007 100644
--- a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh
+++ b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh
@@ -1,117 +1,132 @@
/**
* @file force_based_dirichlet.hh
*
* @author Dana Christen <dana.christen@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief dirichlet boundary condition that tries
* to keep the force at a given value
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_FORCE_BASED_DIRICHLET_HH__
#define __AST_FORCE_BASED_DIRICHLET_HH__
// akantu
#include "aka_common.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class ForceBasedDirichlet : public BC::Dirichlet::IncrementValue {
protected:
typedef const Array<Real> * RealArrayPtr;
typedef const Array<Int> * IntArrayPtr;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ForceBasedDirichlet(SolidMechanicsModel & model, BC::Axis ax, Real target_f,
Real mass = 0.)
: IncrementValue(0., ax), model(model), mass(mass), velocity(0.),
target_force(target_f), total_residual(0.) {}
virtual ~ForceBasedDirichlet() {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void updateTotalResidual() {
SubBoundarySet::iterator it = this->subboundaries.begin();
SubBoundarySet::iterator end = this->subboundaries.end();
this->total_residual = 0.;
for (; it != end; ++it) {
this->total_residual += integrateResidual(*it, this->model, this->axis);
}
}
virtual Real update() {
AKANTU_DEBUG_IN();
this->updateTotalResidual();
Real total_force = this->target_force + this->total_residual;
Real a = total_force / this->mass;
Real dt = model.getTimeStep();
this->velocity += 0.5 * dt * a;
this->value =
this->velocity * dt + 0.5 * dt * dt * a; // increment position dx
this->velocity += 0.5 * dt * a;
AKANTU_DEBUG_OUT();
return this->total_residual;
}
Real applyYourself() {
AKANTU_DEBUG_IN();
Real reaction = this->update();
SubBoundarySet::iterator it = this->subboundaries.begin();
SubBoundarySet::iterator end = this->subboundaries.end();
for (; it != end; ++it) {
this->model.applyBC(*this, *it);
}
AKANTU_DEBUG_OUT();
return reaction;
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_SET_MACRO(Mass, mass, Real);
AKANTU_SET_MACRO(TargetForce, target_force, Real);
void insertSubBoundary(const std::string & sb_name) {
this->subboundaries.insert(sb_name);
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
typedef std::set<std::string> SubBoundarySet;
protected:
SolidMechanicsModel & model;
SubBoundarySet subboundaries;
Real mass;
Real velocity;
Real target_force;
Real total_residual;
};
} // namespace akantu
#endif /* __AST_FORCE_BASED_DIRICHLET_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/inclined_flat_dirichlet.hh b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/inclined_flat_dirichlet.hh
index cc680d96f..805e9b567 100644
--- a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/inclined_flat_dirichlet.hh
+++ b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/inclined_flat_dirichlet.hh
@@ -1,66 +1,81 @@
/**
* @file inclined_flat_dirichlet.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief inclined dirichlet
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_INCLINED_FLAT_DIRICHLET_HH__
#define __AST_INCLINED_FLAT_DIRICHLET_HH__
// akantu
#include "aka_common.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class InclinedFlatDirichlet : public BC::Dirichlet::DirichletFunctor {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
InclinedFlatDirichlet(Real val, BC::Axis ax, BC::Axis incl_ax,
Real center_coord, Real tang)
: DirichletFunctor(ax), value(val), incl_ax(incl_ax),
center_coord(center_coord), tang(tang){};
virtual ~InclinedFlatDirichlet() {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
inline void operator()(UInt node, Vector<bool> & flags, Vector<Real> & primal,
const Vector<Real> & coord) const {
AKANTU_DEBUG_IN();
Real dist = coord(incl_ax) - this->center_coord;
flags(axis) = true;
primal(axis) = this->value + this->tang * dist;
AKANTU_DEBUG_OUT();
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
Real value;
BC::Axis incl_ax;
Real center_coord;
Real tang;
};
} // namespace akantu
#endif /* __AST_INCLINED_FLAT_DIRICHLET_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/spring_bc.hh b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/spring_bc.hh
index d026e1a40..613be1260 100644
--- a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/spring_bc.hh
+++ b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/spring_bc.hh
@@ -1,127 +1,142 @@
/**
* @file spring_bc.hh
*
* @author Dana Christen <dana.christen@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief spring boundary condition
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_SPRING_BC_HH__
#define __AST_SPRING_BC_HH__
// simtools
#include "force_based_dirichlet.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class SpringBC : public ForceBasedDirichlet {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
SpringBC(SolidMechanicsModel & model, BC::Axis ax, Real stiffness,
Real mass = 0.)
: ForceBasedDirichlet(model, ax, 0., mass), stiffness(stiffness),
elongation(0.) {}
virtual ~SpringBC() {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
virtual Real update() {
AKANTU_DEBUG_IN();
this->target_force = -this->stiffness * this->elongation;
Real reaction = ForceBasedDirichlet::update();
this->elongation += this->value;
AKANTU_DEBUG_OUT();
return reaction;
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO(Elongation, elongation, Real);
inline void setToEquilibrium() {
AKANTU_DEBUG_IN();
this->updateTotalResidual();
this->target_force = -this->total_residual;
this->elongation = -this->target_force / this->stiffness;
AKANTU_DEBUG_OUT();
}
/// change elongation
/// dx > 0 -> target_force < 0
inline void incrementElongation(Real dx) {
AKANTU_DEBUG_IN();
this->elongation += dx;
AKANTU_DEBUG_OUT();
}
// friend std::ostream& operator<<(std::ostream& out, const SpringBC &
// spring);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
Real stiffness;
Real elongation;
};
// class SpringBCRestricted : public SpringBC {
// public:
// SpringBCRestricted(BC::Axis ax, Real target_force, BC::Axis surface_axis,
// Real min, Real max)
// :SpringBC(ax, target_force), surface_axis(surface_axis), min(min),
// max(max) {}
// virtual ~SpringBCRestricted() {}
// public:
// inline void operator()(UInt node, Vector<bool> & flags, Vector<Real> &
// primal, const Vector<Real> & coord) const {
// if(coord(surface_axis) > min && coord(surface_axis) < max) {
// SpringBC::operator()(node, flags, primal, coord);
// }
// }
// private:
// BC::Axis surface_axis;
// Real min;
// Real max;
// };
// std::ostream& operator<<(std::ostream& out, const SpringBC & spring) {
// out << "Real total_residual: " << *spring.total_residual << std::endl;
// out << "Real mass: " << spring.mass << std::endl;
// out << "Real k: " << spring.k << std::endl;
// out << "Real delta_x: " << spring.delta_x << std::endl;
// out << "Real dt: " << spring.dt << std::endl;
// out << "Real v: " << spring.v << std::endl;
// out << "Real dx: " << spring.dx << std::endl;
// out << "Real forcing_vel: " << spring.forcing_vel << std::endl;
// return out;
// }
} // namespace akantu
#endif /* __AST_SPRING_BC_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/common/manual_restart.cc b/extra_packages/traction-at-split-node-contact/src/common/manual_restart.cc
index 8abdcd9c5..6b104f28c 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/manual_restart.cc
+++ b/extra_packages/traction-at-split-node-contact/src/common/manual_restart.cc
@@ -1,127 +1,134 @@
/**
* @file manual_restart.cc
*
+ * @author Dana Christen <dana.christen@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
- */
-
-/**
- * @file manual_restart.cc
- * @author Dana Christen <dana.christen@epfl.ch>
- * @date May 15, 2013
+ * 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 "manual_restart.hh"
-
-//#include <iostream>
+#include "dof_manager_default.hh"
+#include "dof_synchronizer.hh"
+/* -------------------------------------------------------------------------- */
#include <fstream>
+/* -------------------------------------------------------------------------- */
using namespace akantu;
void dumpArray(const Array<Real> & array, const std::string & fname) {
std::ofstream outFile;
outFile.open(fname.c_str());
outFile.precision(9);
outFile.setf(std::ios::scientific);
- UInt size = array.getSize();
+ UInt size = array.size();
UInt nb_component = array.getNbComponent();
outFile << size << std::endl;
outFile << nb_component << std::endl;
Array<Real>::const_iterator<Vector<Real>> tit = array.begin(nb_component);
Array<Real>::const_iterator<Vector<Real>> tend = array.end(nb_component);
for (; tit != tend; ++tit) {
for (UInt c = 0; c < nb_component; ++c) {
if (c != 0)
outFile << " ";
outFile << (*tit)(c);
}
outFile << std::endl;
}
outFile.close();
}
void loadArray(Array<Real> & array, const std::string & fname) {
std::ifstream inFile;
inFile.open(fname.c_str());
inFile.precision(9);
inFile.setf(std::ios::scientific);
UInt size(0), nb_comp(0);
inFile >> size;
inFile >> nb_comp;
AKANTU_DEBUG_ASSERT(array.getNbComponent() == nb_comp,
"BAD NUM OF COMPONENTS");
- AKANTU_DEBUG_ASSERT(array.getSize() == size,
+ AKANTU_DEBUG_ASSERT(array.size() == size,
"loadArray: number of data points in file ("
<< size << ") does not correspond to array size ("
- << array.getSize() << ")!!");
+ << array.size() << ")!!");
Array<Real>::iterator<Vector<Real>> tit = array.begin(nb_comp);
Array<Real>::iterator<Vector<Real>> tend = array.end(nb_comp);
array.resize(size);
for (UInt i(0); i < size; ++i, ++tit) {
for (UInt c = 0; c < nb_comp; ++c) {
inFile >> (*tit)(c);
}
}
inFile.close();
}
/* -------------------------------------------------------------------------- */
void loadRestart(akantu::SolidMechanicsModel & model, const std::string & fname,
akantu::UInt prank) {
const akantu::Mesh & mesh = model.getMesh();
const akantu::UInt spatial_dimension = model.getMesh().getSpatialDimension();
-
- const_cast<DOFSynchronizer &>(model.getDOFSynchronizer())
- .initScatterGatherCommunicationScheme();
-
+ auto & dof_manager = dynamic_cast<DOFManagerDefault &>(model.getDOFManager());
if (prank == 0) {
akantu::Array<akantu::Real> full_reload_array(mesh.getNbGlobalNodes(),
spatial_dimension);
loadArray(full_reload_array, fname);
- model.getDOFSynchronizer().scatter(model.getDisplacement(), 0,
- &full_reload_array);
+ dof_manager.getSynchronizer().scatter(model.getDisplacement(),
+ full_reload_array);
} else {
- model.getDOFSynchronizer().scatter(model.getDisplacement(), 0);
+ dof_manager.getSynchronizer().scatter(model.getDisplacement());
}
}
/* -------------------------------------------------------------------------- */
void loadRestart(akantu::SolidMechanicsModel & model,
const std::string & fname) {
loadArray(model.getDisplacement(), fname);
}
/* -------------------------------------------------------------------------- */
void dumpRestart(akantu::SolidMechanicsModel & model, const std::string & fname,
akantu::UInt prank) {
const akantu::Mesh & mesh = model.getMesh();
const akantu::UInt spatial_dimension = model.getMesh().getSpatialDimension();
-
- const_cast<DOFSynchronizer &>(model.getDOFSynchronizer())
- .initScatterGatherCommunicationScheme();
+ auto & dof_manager = dynamic_cast<DOFManagerDefault &>(model.getDOFManager());
if (prank == 0) {
akantu::Array<akantu::Real> full_array(mesh.getNbGlobalNodes(),
spatial_dimension);
- model.getDOFSynchronizer().gather(model.getDisplacement(), 0, &full_array);
+ dof_manager.getSynchronizer().gather(model.getDisplacement(), full_array);
dumpArray(full_array, fname);
} else {
- model.getDOFSynchronizer().gather(model.getDisplacement(), 0);
+ dof_manager.getSynchronizer().gather(model.getDisplacement());
}
}
/* -------------------------------------------------------------------------- */
void dumpRestart(akantu::SolidMechanicsModel & model,
const std::string & fname) {
dumpArray(model.getDisplacement(), fname);
}
diff --git a/extra_packages/traction-at-split-node-contact/src/common/manual_restart.hh b/extra_packages/traction-at-split-node-contact/src/common/manual_restart.hh
index be9d73465..989cede16 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/manual_restart.hh
+++ b/extra_packages/traction-at-split-node-contact/src/common/manual_restart.hh
@@ -1,36 +1,52 @@
/**
* @file manual_restart.hh
*
+ * @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/**
* @file manual_restart.hh
* @author Dana Christen <dana.christen@epfl.ch>
* @date May 15, 2013
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "solid_mechanics_model.hh"
void dumpArray(const akantu::Array<akantu::Real> & array,
const std::string & fname);
void loadArray(akantu::Array<akantu::Real> & array, const std::string & fname);
void loadRestart(akantu::SolidMechanicsModel & model, const std::string & fname,
akantu::UInt prank);
void loadRestart(akantu::SolidMechanicsModel & model,
const std::string & fname);
void dumpRestart(akantu::SolidMechanicsModel & model, const std::string & fname,
akantu::UInt prank);
void dumpRestart(akantu::SolidMechanicsModel & model,
const std::string & fname);
diff --git a/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.cc b/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.cc
index fc2515008..5532c7dfe 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.cc
+++ b/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.cc
@@ -1,441 +1,456 @@
/**
* @file parameter_reader.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of parameter reader
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// std
#include <algorithm>
#include <fstream>
#include <iostream>
#include <utility>
// simtools
#include "parameter_reader.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
ParameterReader::ParameterReader()
: data_types(), element_type_data(), string_data(), int_data(), uint_data(),
real_data(), bool_data() {
AKANTU_DEBUG_IN();
// setup of types of element
data_types.insert("elementtype");
data_types.insert("string");
data_types.insert("uint");
data_types.insert("int");
data_types.insert("real");
data_types.insert("bool");
// data_types.insert("surface");
// define conversion maps
_input_to_akantu_element_types["_segment_2"] = akantu::_segment_2;
_input_to_akantu_element_types["_segment_3"] = akantu::_segment_3;
_input_to_akantu_element_types["_triangle_3"] = akantu::_triangle_3;
_input_to_akantu_element_types["_triangle_6"] = akantu::_triangle_6;
_input_to_akantu_element_types["_tetrahedron_4"] = akantu::_tetrahedron_4;
_input_to_akantu_element_types["_tetrahedron_10"] = akantu::_tetrahedron_10;
_input_to_akantu_element_types["_quadrangle_4"] = akantu::_quadrangle_4;
_input_to_akantu_element_types["_quadrangle_8"] = akantu::_quadrangle_8;
_input_to_akantu_element_types["_hexahedron_8"] = akantu::_hexahedron_8;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void ParameterReader::readInputFile(std::string file_name) {
AKANTU_DEBUG_IN();
char comment_char = '#';
char equal_char = '=';
// open a file called file name
std::ifstream infile;
infile.open(file_name.c_str());
if (!infile.good()) {
std::cerr << "Cannot open file " << file_name << "!!!" << std::endl;
exit(EXIT_FAILURE);
}
std::string line;
std::string clean_line;
while (infile.good()) {
getline(infile, line);
clean_line = line;
// take out comments
size_t found_comment;
found_comment = line.find_first_of(comment_char);
if (found_comment != std::string::npos)
clean_line = line.substr(0, found_comment);
if (clean_line.empty())
continue;
std::stringstream sstr(clean_line);
// check if data type exists
std::string type;
sstr >> type;
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
if (this->data_types.find(type) == this->data_types.end()) {
std::cerr << " *** WARNING *** Data type " << type << " does not exist"
<< " in this input data structure. Ignore line: ";
std::cerr << clean_line << std::endl;
continue;
}
std::string keyword;
std::string equal;
std::string value;
// get keyword
sstr >> keyword;
size_t equal_p = keyword.find_first_of(equal_char);
if (equal_p != std::string::npos) {
equal = keyword.substr(equal_p, std::string::npos);
keyword = keyword.substr(0, equal_p);
}
// get equal
if (equal.empty())
sstr >> equal;
if (equal.length() != 1) {
value = equal.substr(1, std::string::npos);
equal = equal[0];
}
if (equal[0] != equal_char) {
std::cerr << " *** WARNING *** Unrespected convention! Ignore line: ";
std::cerr << clean_line << std::endl;
continue;
}
// get value
if (value.empty())
sstr >> value;
// no value
if (value.empty()) {
std::cerr << " *** WARNING *** No value given! Ignore line: ";
std::cerr << clean_line << std::endl;
continue;
}
// put value in map
std::stringstream convert(value);
if (type.compare("elementtype") == 0) {
std::map<std::string, akantu::ElementType>::const_iterator it;
it = this->_input_to_akantu_element_types.find(value);
if (it != this->_input_to_akantu_element_types.end())
this->element_type_data.insert(std::make_pair(keyword, it->second));
else {
std::cerr << " *** WARNING *** ElementType " << value
<< " does not exist. Ignore line: ";
std::cerr << clean_line << std::endl;
continue;
}
} else if (type.compare("string") == 0) {
this->string_data.insert(std::make_pair(keyword, value));
}
/*
else if (type.compare("surface") == 0) {
//Surface surf;
UInt surf;
convert >> surf;
//this->surface_data.insert(std::make_pair(keyword,surf));
this->uint_data.insert(std::make_pair(keyword,surf));
}
*/
else if (type.compare("int") == 0) {
Int i;
convert >> i;
this->int_data.insert(std::make_pair(keyword, i));
} else if (type.compare("uint") == 0) {
UInt i;
convert >> i;
this->uint_data.insert(std::make_pair(keyword, i));
} else if (type.compare("real") == 0) {
Real r;
convert >> r;
this->real_data.insert(std::make_pair(keyword, r));
} else if (type.compare("bool") == 0) {
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
bool b;
if (value.compare("true") == 0)
b = true;
else if (value.compare("false") == 0)
b = false;
else {
std::cerr << " *** WARNING *** boolean cannot be " << value
<< ". Ignore line: ";
std::cerr << clean_line << std::endl;
continue;
}
this->bool_data.insert(std::make_pair(keyword, b));
} else {
std::cerr << " *** ERROR *** Could not add data to InputData for line: ";
std::cerr << clean_line << std::endl;
continue;
exit(EXIT_FAILURE);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void ParameterReader::writeInputFile(std::string file_name) const {
AKANTU_DEBUG_IN();
// open file to write input information
std::ofstream outfile;
outfile.open(file_name.c_str());
// element type
for (std::map<std::string, akantu::ElementType>::const_iterator it =
element_type_data.begin();
it != element_type_data.end(); ++it) {
for (std::map<std::string, ElementType>::const_iterator et =
_input_to_akantu_element_types.begin();
et != _input_to_akantu_element_types.end(); ++et) {
if (it->second == et->second) {
outfile << "ElementType " << it->first << " = " << et->first
<< std::endl;
continue;
}
}
}
// string
for (std::map<std::string, std::string>::const_iterator it =
string_data.begin();
it != string_data.end(); ++it)
outfile << "string " << it->first << " = " << it->second << std::endl;
// Surface
/*
for (std::map<std::string, akantu::Surface>::const_iterator it =
surface_data.begin();
it != surface_data.end(); ++it)
outfile << "Surface " << it->first << " = " << it->second << std::endl;
*/
// Int
for (std::map<std::string, akantu::Int>::const_iterator it = int_data.begin();
it != int_data.end(); ++it)
outfile << "Int " << it->first << " = " << it->second << std::endl;
// UInt
for (std::map<std::string, akantu::UInt>::const_iterator it =
uint_data.begin();
it != uint_data.end(); ++it)
outfile << "UInt " << it->first << " = " << it->second << std::endl;
// Real
for (std::map<std::string, akantu::Real>::const_iterator it =
real_data.begin();
it != real_data.end(); ++it)
outfile << "Real " << it->first << " = " << it->second << std::endl;
// Bool
for (std::map<std::string, bool>::const_iterator it = bool_data.begin();
it != bool_data.end(); ++it) {
std::string b = "false";
if (it->second)
b = "true";
outfile << "bool " << it->first << " = " << b << std::endl;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <>
akantu::UInt ParameterReader::get<akantu::UInt>(std::string key) const {
std::map<std::string, akantu::UInt>::const_iterator it;
it = this->uint_data.find(key);
// if not in map
if (it == this->uint_data.end()) {
std::cerr << " *** ERROR *** This data was not in input file. "
<< "You need the following line in your input file: ";
std::cerr << "UInt " << key << " = ???" << std::endl;
exit(EXIT_FAILURE);
}
else
return it->second;
}
/* -------------------------------------------------------------------------- */
template <>
akantu::ElementType
ParameterReader::get<akantu::ElementType>(std::string key) const {
std::map<std::string, akantu::ElementType>::const_iterator it;
it = this->element_type_data.find(key);
// if not in map
if (it == this->element_type_data.end()) {
std::cerr << " *** ERROR *** This data was not in input file. "
<< "You need the following line in your input file: ";
std::cerr << "ElementType " << key << " = ???" << std::endl;
exit(EXIT_FAILURE);
}
else
return it->second;
}
/* -------------------------------------------------------------------------- */
template <>
std::string ParameterReader::get<std::string>(std::string key) const {
std::map<std::string, std::string>::const_iterator it;
it = this->string_data.find(key);
// if not in map
if (it == this->string_data.end()) {
std::cerr << " *** ERROR *** This data was not in input file. "
<< "You need the following line in your input file: ";
std::cerr << "string " << key << " = ???" << std::endl;
exit(EXIT_FAILURE);
}
else
return it->second;
}
/* -------------------------------------------------------------------------- */
/*
template<>
akantu::Surface ParameterData::get<akantu::Surface>(std::string key) const {
std::map<std::string,akantu::Surface>::const_iterator it;
it = this->surface_data.find(key);
// if not in map
if (it == this->surface_data.end()) {
std::cerr << " *** ERROR *** This data was not in input file. "
<< "You need the following line in your input file: ";
std::cerr << "Surface " << key << " = ???" << std::endl;
exit(EXIT_FAILURE);
}
else
return it->second;
}
*/
/* -------------------------------------------------------------------------- */
template <>
akantu::Int ParameterReader::get<akantu::Int>(std::string key) const {
std::map<std::string, akantu::Int>::const_iterator it;
it = this->int_data.find(key);
// if not in map
if (it == this->int_data.end()) {
std::cerr << " *** ERROR *** This data was not in input file. "
<< "You need the following line in your input file: ";
std::cerr << "Int " << key << " = ???" << std::endl;
exit(EXIT_FAILURE);
}
else
return it->second;
}
/* -------------------------------------------------------------------------- */
template <>
akantu::Real ParameterReader::get<akantu::Real>(std::string key) const {
std::map<std::string, akantu::Real>::const_iterator it;
it = this->real_data.find(key);
// if not in map
if (it == this->real_data.end()) {
std::cerr << " *** ERROR *** This data was not in input file. "
<< "You need the following line in your input file: ";
std::cerr << "Real " << key << " = ???" << std::endl;
exit(EXIT_FAILURE);
}
else
return it->second;
}
/* -------------------------------------------------------------------------- */
template <> bool ParameterReader::get<bool>(std::string key) const {
std::map<std::string, bool>::const_iterator it;
it = this->bool_data.find(key);
// if not in map
if (it == this->bool_data.end()) {
std::cerr << " *** ERROR *** This data was not in input file. "
<< "You need the following line in your input file: ";
std::cerr << "bool " << key << " = ???" << std::endl;
exit(EXIT_FAILURE);
}
else
return it->second;
}
/* -------------------------------------------------------------------------- */
template <> bool ParameterReader::has<bool>(std::string key) const {
std::map<std::string, bool>::const_iterator it;
it = this->bool_data.find(key);
return (it != this->bool_data.end());
}
template <> bool ParameterReader::has<std::string>(std::string key) const {
std::map<std::string, std::string>::const_iterator it;
it = this->string_data.find(key);
return (it != this->string_data.end());
}
template <> bool ParameterReader::has<akantu::Int>(std::string key) const {
std::map<std::string, akantu::Int>::const_iterator it;
it = this->int_data.find(key);
return (it != this->int_data.end());
}
template <> bool ParameterReader::has<akantu::UInt>(std::string key) const {
std::map<std::string, akantu::UInt>::const_iterator it;
it = this->uint_data.find(key);
return (it != this->uint_data.end());
}
template <> bool ParameterReader::has<akantu::Real>(std::string key) const {
std::map<std::string, akantu::Real>::const_iterator it;
it = this->real_data.find(key);
return (it != this->real_data.end());
}
/* -------------------------------------------------------------------------- */
void ParameterReader::printself(std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "ParameterReader [" << std::endl;
/*
stream << space << this->element_type_data << std::endl;
stream << space << this->string_data << std::endl;
stream << space << this->surface_data << std::endl;
stream << space << this->int_data << std::endl;
stream << space << this->uint_data << std::endl;
stream << space << this->real_data << std::endl;
stream << space << this->bool_data << std::endl;
*/
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.hh b/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.hh
index f1e39a68d..0583e6006 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.hh
+++ b/extra_packages/traction-at-split-node-contact/src/common/parameter_reader.hh
@@ -1,95 +1,110 @@
/**
* @file parameter_reader.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief for simulations to read parameters from an input file
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_PARAMETER_READER_HH__
#define __AST_PARAMETER_READER_HH__
/* -------------------------------------------------------------------------- */
// std
#include <map>
#include <set>
// akantu
#include "aka_common.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class ParameterReader {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ParameterReader();
virtual ~ParameterReader(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// read input file
void readInputFile(std::string file_name);
/// write input file
void writeInputFile(std::string file_name) const;
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
///
template <typename T> T get(std::string key) const;
template <typename T> bool has(std::string key) const;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// type of data available
std::set<std::string> data_types;
/// data
std::map<std::string, akantu::ElementType> element_type_data;
std::map<std::string, std::string> string_data;
std::map<std::string, akantu::Int> int_data;
std::map<std::string, akantu::UInt> uint_data;
std::map<std::string, akantu::Real> real_data;
std::map<std::string, bool> bool_data;
/// convert string to element type
std::map<std::string, ElementType> _input_to_akantu_element_types;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "parameter_reader_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const ParameterReader & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_PARAMETER_READER_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc
index f2d0bd016..26e97e945 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc
+++ b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc
@@ -1,230 +1,245 @@
/**
* @file synchronized_array.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of synchronized array function
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// std
#include <fstream>
#include <iostream>
// simtools
#include "synchronized_array.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class T>
SynchronizedArray<T>::SynchronizedArray(
UInt size, UInt nb_component, SynchronizedArray<T>::const_reference value,
const ID & id, SynchronizedArray<T>::const_reference default_value,
const std::string restart_name)
: SynchronizedArrayBase(), Array<T>(size, nb_component, value, id),
default_value(default_value), restart_name(restart_name),
deleted_elements(0), nb_added_elements(size), depending_arrays(0) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class T>
void SynchronizedArray<T>::syncElements(SyncChoice sync_choice) {
AKANTU_DEBUG_IN();
if (sync_choice == _deleted) {
std::vector<SynchronizedArrayBase *>::iterator it;
for (it = depending_arrays.begin(); it != depending_arrays.end(); ++it) {
UInt vec_size = (*it)->syncDeletedElements(this->deleted_elements);
- AKANTU_DEBUG_ASSERT(vec_size == this->size,
+ AKANTU_DEBUG_ASSERT(vec_size == this->size_,
"Synchronized arrays do not have the same length"
<< "(may be a double synchronization)");
}
this->deleted_elements.clear();
}
else if (sync_choice == _added) {
std::vector<SynchronizedArrayBase *>::iterator it;
for (it = depending_arrays.begin(); it != depending_arrays.end(); ++it) {
UInt vec_size = (*it)->syncAddedElements(this->nb_added_elements);
- AKANTU_DEBUG_ASSERT(vec_size == this->size,
+ AKANTU_DEBUG_ASSERT(vec_size == this->size_,
"Synchronized arrays do not have the same length"
<< "(may be a double synchronization)");
}
this->nb_added_elements = 0;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class T>
UInt SynchronizedArray<T>::syncDeletedElements(
std::vector<UInt> & del_elements) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(
nb_added_elements == 0 && deleted_elements.size() == 0,
"Cannot sync with a SynchronizedArray if it has already been modified");
std::vector<UInt>::const_iterator it;
for (it = del_elements.begin(); it != del_elements.end(); ++it) {
erase(*it);
}
syncElements(_deleted);
AKANTU_DEBUG_OUT();
- return this->size;
+ return this->size_;
}
/* -------------------------------------------------------------------------- */
template <class T>
UInt SynchronizedArray<T>::syncAddedElements(UInt nb_add_elements) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(
nb_added_elements == 0 && deleted_elements.size() == 0,
"Cannot sync with a SynchronizedArray if it has already been modified");
for (UInt i = 0; i < nb_add_elements; ++i) {
push_back(this->default_value);
}
syncElements(_added);
AKANTU_DEBUG_OUT();
- return this->size;
+ return this->size_;
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::registerDependingArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->depending_arrays.push_back(&array);
- array.syncAddedElements(this->size);
+ array.syncAddedElements(this->size_);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::printself(std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "SynchronizedArray<" << debug::demangle(typeid(T).name())
<< "> [" << std::endl;
stream << space << " + default_value : " << this->default_value
<< std::endl;
stream << space << " + nb_added_elements : " << this->nb_added_elements
<< std::endl;
stream << space << " + deleted_elements : ";
for (std::vector<UInt>::const_iterator it = this->deleted_elements.begin();
it != this->deleted_elements.end(); ++it)
stream << *it << " ";
stream << std::endl;
stream << space << " + depending_arrays : ";
for (std::vector<SynchronizedArrayBase *>::const_iterator it =
this->depending_arrays.begin();
it != this->depending_arrays.end(); ++it)
stream << (*it)->getID() << " ";
stream << std::endl;
Array<T>::printself(stream, indent + 1);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::dumpRestartFile(std::string file_name) const {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(
nb_added_elements == 0 && deleted_elements.size() == 0,
"Restart File for SynchronizedArray "
<< this->id << " should not be dumped as it is not synchronized yet");
std::stringstream name;
name << file_name << "-" << this->restart_name << ".rs";
std::ofstream out_restart;
out_restart.open(name.str().c_str());
- out_restart << this->size << " " << this->nb_component << std::endl;
- Real size_comp = this->size * this->nb_component;
+ out_restart << this->size_ << " " << this->nb_component << std::endl;
+ Real size_comp = this->size_ * this->nb_component;
for (UInt i = 0; i < size_comp; ++i)
out_restart << std::setprecision(12) << this->values[i] << " ";
// out_restart << std::hex << std::setprecision(12) << this->values[i] << "
// ";
out_restart << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::readRestartFile(std::string file_name) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(
nb_added_elements == 0 && deleted_elements.size() == 0,
"Restart File for SynchronizedArray "
<< this->id << " should not be read as it is not synchronized yet");
std::stringstream name;
name << file_name << "-" << this->restart_name << ".rs";
std::ifstream infile;
infile.open(name.str().c_str());
std::string line;
// get size and nb_component info
AKANTU_DEBUG_ASSERT(infile.good(),
"Could not read restart file for "
<< "SynchronizedArray " << this->id);
getline(infile, line);
std::stringstream size_comp(line);
- size_comp >> this->size;
+ size_comp >> this->size_;
size_comp >> this->nb_component;
// get elements in array
getline(infile, line);
std::stringstream data(line);
- for (UInt i = 0; i < this->size * this->nb_component; ++i) {
+ for (UInt i = 0; i < this->size_ * this->nb_component; ++i) {
AKANTU_DEBUG_ASSERT(
!data.eof(),
"Read SynchronizedArray "
<< this->id
<< " got to the end of the file before having read all data!");
data >> this->values[i];
// data >> std::hex >> this->values[i];
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template class SynchronizedArray<Real>;
template class SynchronizedArray<UInt>;
template class SynchronizedArray<Int>;
template class SynchronizedArray<bool>;
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.hh b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.hh
index c3bb398db..7ec3c68b8 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.hh
+++ b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.hh
@@ -1,190 +1,204 @@
/**
* @file synchronized_array.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief synchronized array: a array can be registered to another (hereafter
* called top) array. If an element is added to or removed from the top array,
* the registered array removes or adds at the same position an element. The two
* arrays stay therefore synchronized.
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_SYNCHRONIZED_ARRAY_HH__
#define __AST_SYNCHRONIZED_ARRAY_HH__
/* -------------------------------------------------------------------------- */
// std
#include <vector>
// akantu
#include "aka_array.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
enum SyncChoice { _added, _deleted };
/* -------------------------------------------------------------------------- */
class SynchronizedArrayBase {
public:
SynchronizedArrayBase(){};
~SynchronizedArrayBase(){};
virtual ID getID() const { return "call should be virtual"; };
virtual UInt syncDeletedElements(std::vector<UInt> & delete_el) = 0;
virtual UInt syncAddedElements(UInt nb_added_el) = 0;
};
/* -------------------------------------------------------------------------- */
template <class T>
class SynchronizedArray : public SynchronizedArrayBase, protected Array<T> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
typedef typename Array<T>::value_type value_type;
typedef typename Array<T>::reference reference;
typedef typename Array<T>::pointer_type pointer_type;
typedef typename Array<T>::const_reference const_reference;
SynchronizedArray(UInt size, UInt nb_component, const_reference value,
const ID & id, const_reference default_value,
const std::string restart_name);
virtual ~SynchronizedArray(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// push_back
- inline void push_back(const_reference value);
- inline void push_back(const value_type new_element[]);
+ template <typename P> inline void push_back(P && value);
/// erase
inline void erase(UInt i);
// template<typename R>
// inline void erase(const iterator<R> & it);
/// synchronize elements
void syncElements(SyncChoice sync_choice);
/// dump restart file
void dumpRestartFile(std::string file_name) const;
/// read restart file
void readRestartFile(std::string file_name);
/// register depending array
void registerDependingArray(SynchronizedArrayBase & array);
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
/// find position of element
Int find(const T & elem) const { return Array<T>::find(elem); };
/// set values to zero
inline void clear() { Array<T>::clear(); };
// inline void clear() { memset(values, 0, size*nb_component*sizeof(T)); };
/// set all entries of the array to the value t
/// @param t value to fill the array with
inline void set(T t) { Array<T>::set(t); }
/// set
template <template <typename> class C> inline void set(const C<T> & vm) {
Array<T>::set(vm);
- };
+ }
/// set all entries of the array to value t and set default value
inline void setAndChangeDefault(T t) {
this->set(t);
this->default_value = t;
}
/// copy the content of an other array
void copy(const SynchronizedArray<T> & vect) { Array<T>::copy(vect); };
/// give the address of the memory allocated for this array
T * storage() const { return Array<T>::storage(); };
// T * storage() const { return this->values; };
// get nb component
UInt getNbComponent() const { return Array<T>::getNbComponent(); };
protected:
UInt syncDeletedElements(std::vector<UInt> & del_elements);
UInt syncAddedElements(UInt nb_add_elements);
/* ------------------------------------------------------------------------ */
/* Operators */
/* ------------------------------------------------------------------------ */
public:
inline reference operator()(UInt i, UInt j = 0) {
return Array<T>::operator()(i, j);
}
inline const_reference operator()(UInt i, UInt j = 0) const {
return Array<T>::operator()(i, j);
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_SET_MACRO(DefaultValue, default_value, T);
- UInt getSize() const { return this->size; };
+ UInt size() const { return this->size_; };
ID getID() const { return Array<T>::getID(); };
const Array<T> & getArray() const {
const Array<T> & a = *(dynamic_cast<const Array<T> *>(this));
return a;
};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// init value when new elements added
T default_value;
/// restart file_name
const std::string restart_name;
/// elements that have been deleted
std::vector<UInt> deleted_elements;
/// number of elements to add
UInt nb_added_elements;
/// pointers to arrays to be updated
std::vector<SynchronizedArrayBase *> depending_arrays;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "synchronized_array_inline_impl.cc"
/// standard output stream operator
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
const SynchronizedArray<T> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_SYNCHRONIZED_ARRAY_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array_inline_impl.cc b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array_inline_impl.cc
index adbf39076..e829f11ac 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array_inline_impl.cc
+++ b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array_inline_impl.cc
@@ -1,73 +1,74 @@
/**
* @file synchronized_array_inline_impl.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief inlined methods for the synchronized array
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
template <typename T>
-inline void SynchronizedArray<T>::push_back(const_reference value) {
- AKANTU_DEBUG_IN();
-
- AKANTU_DEBUG_ASSERT(deleted_elements.size() == 0,
- "Cannot push_back element if SynchronizedArray"
- << " is already modified without synchronization");
-
- Array<T>::push_back(value);
- this->nb_added_elements++;
-
- AKANTU_DEBUG_OUT();
-}
-
-/* -------------------------------------------------------------------------- */
-template <typename T>
-inline void SynchronizedArray<T>::push_back(const value_type new_elem[]) {
+template <typename P>
+inline void SynchronizedArray<T>::push_back(P && value) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(deleted_elements.size() == 0,
"Cannot push_back element if SynchronizedArray"
<< " is already modified without synchronization");
- Array<T>::push_back(new_elem);
+ Array<T>::push_back(std::forward<P>(value));
this->nb_added_elements++;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T> inline void SynchronizedArray<T>::erase(UInt i) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(nb_added_elements == 0,
"Cannot erase element if SynchronizedArray"
<< " is already modified without synchronization");
for (UInt j = 0; j < this->nb_component; ++j)
this->values[i * this->nb_component + j] =
- this->values[(this->size - 1) * this->nb_component + j];
- this->size--;
+ this->values[(this->size_ - 1) * this->nb_component + j];
+ this->size_--;
this->deleted_elements.push_back(i);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/*
template<typename T>
template<typename R>
inline void SynchronizedArray<T>::erase(const iterator<R> & it) {
T * curr = it.getCurrentStorage();
UInt pos = (curr - values) / nb_component;
erase(pos);
}
*/
diff --git a/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc b/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc
index bb60d7467..99985a041 100644
--- a/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc
+++ b/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc
@@ -1,63 +1,73 @@
/**
* @file boundary_functions.cc
*
+ * @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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 "boundary_functions.hh"
+#include "communicator.hh"
+/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Real integrateResidual(const std::string & sub_boundary_name,
const SolidMechanicsModel & model, UInt dir) {
Real int_res = 0.;
const Mesh & mesh = model.getMesh();
- const Array<Real> & residual = model.getResidual();
+ const Array<Real> & residual = model.getInternalForce();
- // do not need try catch, as all subboundaries should be everywhere.
- // try {
const ElementGroup & boundary = mesh.getElementGroup(sub_boundary_name);
- ElementGroup::const_node_iterator nit = boundary.node_begin();
- ElementGroup::const_node_iterator nend = boundary.node_end();
- for (; nit != nend; ++nit) {
- bool is_local_node = mesh.isLocalOrMasterNode(*nit);
+ for (auto & node : boundary.getNodes()) {
+ bool is_local_node = mesh.isLocalOrMasterNode(node);
if (is_local_node) {
- int_res += residual(*nit, dir);
+ int_res += residual(node, dir);
}
}
- // } catch(debug::Exception e) {
- // // AKANTU_ERROR("Error computing integrateResidual. Cannot get
- // SubBoundary: "
- // // << sub_boundary_name << " [" << e.what() << "]");
- // }
- StaticCommunicator::getStaticCommunicator().allReduce(&int_res, 1, _so_sum);
+ mesh.getCommunicator().allReduce(int_res, SynchronizerOperation::_sum);
return int_res;
}
/* -------------------------------------------------------------------------- */
void boundaryFix(Mesh & mesh,
const std::vector<std::string> & sub_boundary_names) {
std::vector<std::string>::const_iterator it = sub_boundary_names.begin();
std::vector<std::string>::const_iterator end = sub_boundary_names.end();
for (; it != end; ++it) {
if (mesh.element_group_find(*it) == mesh.element_group_end()) {
mesh.createElementGroup(
*it, mesh.getSpatialDimension() - 1); // empty element group
}
}
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.hh b/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.hh
index 89fd859e3..a16426a6c 100644
--- a/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.hh
+++ b/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.hh
@@ -1,30 +1,45 @@
/**
* @file boundary_functions.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jan 04 2013
+ * @date last modification: Fri Feb 23 2018
*
* @brief functions for boundaries
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2014-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// akantu
#include "aka_common.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
Real integrateResidual(const std::string & sub_boundary_name,
const SolidMechanicsModel & model, UInt dir);
/// this is a fix so that all subboundaries exist on all procs
void boundaryFix(Mesh & mesh,
const std::vector<std::string> & sub_boundary_names);
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/functions/node_filter.hh b/extra_packages/traction-at-split-node-contact/src/functions/node_filter.hh
index daad5b664..f6c03790c 100644
--- a/extra_packages/traction-at-split-node-contact/src/functions/node_filter.hh
+++ b/extra_packages/traction-at-split-node-contact/src/functions/node_filter.hh
@@ -1,98 +1,113 @@
/**
* @file node_filter.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Tue Feb 20 2018
*
* @brief to filter nodes with functors
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NODE_FILTER_HH__
#define __AST_NODE_FILTER_HH__
/* -------------------------------------------------------------------------- */
// akantu
#include "aka_common.hh"
#include "mesh_filter.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class GeometryFilter : public NodeFilterFunctor {
public:
GeometryFilter(const Mesh & mesh, UInt dir, Real limit)
: NodeFilterFunctor(), mesh(mesh), dir(dir), limit(limit) {
this->positions = &(mesh.getNodes());
};
~GeometryFilter(){};
bool operator()(UInt node) { AKANTU_TO_IMPLEMENT(); };
protected:
const Mesh & mesh;
UInt dir;
Real limit;
const Array<Real> * positions;
};
/* -------------------------------------------------------------------------- */
class FilterPositionsGreaterThan : public GeometryFilter {
public:
FilterPositionsGreaterThan(const Mesh & mesh, UInt dir, Real limit)
: GeometryFilter(mesh, dir, limit){};
~FilterPositionsGreaterThan(){};
bool operator()(UInt node) {
AKANTU_DEBUG_IN();
bool to_filter = true;
if ((*this->positions)(node, this->dir) > this->limit)
to_filter = false;
AKANTU_DEBUG_OUT();
return to_filter;
};
};
/* -------------------------------------------------------------------------- */
class FilterPositionsLessThan : public GeometryFilter {
public:
FilterPositionsLessThan(const Mesh & mesh, UInt dir, Real limit)
: GeometryFilter(mesh, dir, limit){};
~FilterPositionsLessThan(){};
bool operator()(UInt node) {
AKANTU_DEBUG_IN();
bool to_filter = true;
if ((*this->positions)(node, this->dir) < this->limit)
to_filter = false;
AKANTU_DEBUG_OUT();
return to_filter;
};
};
/* -------------------------------------------------------------------------- */
// this filter is erase because the convention of filter has changed!!
// filter == true -> keep node
// template<class FilterType>
// void applyNodeFilter(Array<UInt> & nodes, FilterType & filter) {
// Array<UInt>::iterator<> it = nodes.begin();
// for (; it != nodes.end(); ++it) {
// if (filter(*it)) {
// it = nodes.erase(it);
// }
// }
// };
} // namespace akantu
#endif /* __AST_NODE_FILTER_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh
index d910acc3c..0cc6df6dd 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb.hh
@@ -1,93 +1,108 @@
/**
* @file ntn_friclaw_coulomb.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief coulomb friction with \mu_s = \mu_k (constant)
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICLAW_COULOMB_HH__
#define __AST_NTN_FRICLAW_COULOMB_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_no_regularisation.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation = NTNFricRegNoRegularisation>
class NTNFricLawCoulomb : public Regularisation {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricLawCoulomb(NTNBaseContact * contact, const FrictionID & id = "coulomb",
const MemoryID & memory_id = 0);
virtual ~NTNFricLawCoulomb(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// register synchronizedarrays for sync
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
/// dump restart file
virtual void dumpRestart(const std::string & file_name) const;
/// read restart file
virtual void readRestart(const std::string & file_name);
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// compute frictional strength according to friction law
virtual void computeFrictionalStrength();
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
// friction coefficient
SynchronizedArray<Real> mu;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template <class Regularisation>
inline std::ostream &
operator<<(std::ostream & stream,
const NTNFricLawCoulomb<Regularisation> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "ntn_friclaw_coulomb_tmpl.hh"
#endif /* __AST_NTN_FRICLAW_COULOMB_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh
index df0841947..d012fb969 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh
@@ -1,153 +1,168 @@
/**
* @file ntn_friclaw_coulomb_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of coulomb friction
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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 "dumper_nodal_field.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawCoulomb<Regularisation>::NTNFricLawCoulomb(NTNBaseContact * contact,
const FrictionID & id,
const MemoryID & memory_id)
: Regularisation(contact, id, memory_id),
mu(0, 1, 0., id + ":mu", 0., "mu") {
AKANTU_DEBUG_IN();
Regularisation::registerSynchronizedArray(this->mu);
this->registerParam("mu", this->mu, _pat_parsmod, "friction coefficient");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::computeFrictionalStrength() {
AKANTU_DEBUG_IN();
// get contact arrays
const SynchronizedArray<bool> & is_in_contact =
this->internalGetIsInContact();
const SynchronizedArray<Real> & pressure = this->internalGetContactPressure();
// array to fill
SynchronizedArray<Real> & strength = this->internalGetFrictionalStrength();
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
strength(n) = 0.;
// node pair is in contact
else {
// compute frictional strength
strength(n) = this->mu(n) * pressure(n);
}
}
Regularisation::computeFrictionalStrength();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->mu.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::dumpRestart(
const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->mu.dumpRestartFile(file_name);
Regularisation::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::readRestart(
const std::string & file_name) {
AKANTU_DEBUG_IN();
this->mu.readRestartFile(file_name);
Regularisation::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::printself(std::ostream & stream,
int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFricLawCoulomb [" << std::endl;
Regularisation::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact->getSlaves());
if (field_id == "mu") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->mu.getArray()));
}
/*
else if (field_id == "frictional_contact_pressure") {
this->internalAddDumpFieldToDumper(dumper_name,
field_id,
new
DumperIOHelper::NodalField<Real>(this->frictional_contact_pressure.getArray()));
}
*/
else {
Regularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh
index 26a84a24f..a6bb69a06 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive.hh
@@ -1,100 +1,115 @@
/**
* @file ntn_friclaw_linear_cohesive.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief linear cohesive law
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICLAW_LINEAR_COHESIVE_HH__
#define __AST_NTN_FRICLAW_LINEAR_COHESIVE_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_no_regularisation.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation = NTNFricRegNoRegularisation>
class NTNFricLawLinearCohesive : public Regularisation {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricLawLinearCohesive(NTNBaseContact * contact,
const FrictionID & id = "linear_cohesive",
const MemoryID & memory_id = 0);
virtual ~NTNFricLawLinearCohesive(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// register synchronizedarrays for sync
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
/// dump restart file
virtual void dumpRestart(const std::string & file_name) const;
/// read restart file
virtual void readRestart(const std::string & file_name);
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// compute frictional strength according to friction law
virtual void computeFrictionalStrength();
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
// fracture energy
SynchronizedArray<Real> G_c;
// peak value of cohesive law
SynchronizedArray<Real> tau_c;
// residual value of cohesive law (for slip > d_c)
SynchronizedArray<Real> tau_r;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template <class Regularisation>
inline std::ostream &
operator<<(std::ostream & stream,
const NTNFricLawLinearCohesive<Regularisation> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "ntn_friclaw_linear_cohesive_tmpl.hh"
#endif /* __AST_NTN_FRICLAW_LINEAR_COHESIVE_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh
index 0e72a085d..bd9fe4f2d 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh
@@ -1,174 +1,189 @@
/**
* @file ntn_friclaw_linear_cohesive_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of linear cohesive law
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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 "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawLinearCohesive<Regularisation>::NTNFricLawLinearCohesive(
NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id)
: Regularisation(contact, id, memory_id),
G_c(0, 1, 0., id + ":G_c", 0., "G_c"),
tau_c(0, 1, 0., id + ":tau_c", 0., "tau_c"),
tau_r(0, 1, 0., id + ":tau_r", 0., "tau_r") {
AKANTU_DEBUG_IN();
Regularisation::registerSynchronizedArray(this->G_c);
Regularisation::registerSynchronizedArray(this->tau_c);
Regularisation::registerSynchronizedArray(this->tau_r);
this->registerParam("G_c", this->G_c, _pat_parsmod, "fracture energy");
this->registerParam("tau_c", this->tau_c, _pat_parsmod,
"peak shear strength");
this->registerParam("tau_r", this->tau_r, _pat_parsmod,
"residual shear strength");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::computeFrictionalStrength() {
AKANTU_DEBUG_IN();
// get arrays
const SynchronizedArray<bool> & is_in_contact =
this->internalGetIsInContact();
// const SynchronizedArray<Real> & slip = this->internalGetSlip();
const SynchronizedArray<Real> & slip = this->internalGetCumulativeSlip();
// array to fill
SynchronizedArray<Real> & strength = this->internalGetFrictionalStrength();
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
strength(n) = 0.;
// node pair is in contact
else {
if (this->G_c(n) == 0.) {
// strength(n) = 0.;
strength(n) = this->tau_r(n);
} else {
Real slope = (this->tau_c(n) - this->tau_r(n)) *
(this->tau_c(n) - this->tau_r(n)) / (2 * this->G_c(n));
// no strength < tau_r
strength(n) =
std::max(this->tau_c(n) - slope * slip(n), this->tau_r(n));
// strength(n) = std::max(this->tau_c(n) - slope * slip(n), 0.); // no
// negative strength
}
}
}
Regularisation::computeFrictionalStrength();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->G_c.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::dumpRestart(
const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->G_c.dumpRestartFile(file_name);
this->tau_c.dumpRestartFile(file_name);
this->tau_r.dumpRestartFile(file_name);
Regularisation::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::readRestart(
const std::string & file_name) {
AKANTU_DEBUG_IN();
this->G_c.readRestartFile(file_name);
this->tau_c.readRestartFile(file_name);
this->tau_r.readRestartFile(file_name);
Regularisation::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::printself(std::ostream & stream,
int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFricLawLinearCohesive [" << std::endl;
Regularisation::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact->getSlaves());
if (field_id == "G_c") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->G_c.getArray()));
} else if (field_id == "tau_c") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->tau_c.getArray()));
} else if (field_id == "tau_r") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->tau_r.getArray()));
} else {
Regularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh
index c0cdb03e0..b95d989c0 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening.hh
@@ -1,102 +1,117 @@
/**
* @file ntn_friclaw_linear_slip_weakening.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief linear slip weakening
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_HH__
#define __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_friclaw_coulomb.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation = NTNFricRegNoRegularisation>
class NTNFricLawLinearSlipWeakening : public NTNFricLawCoulomb<Regularisation> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricLawLinearSlipWeakening(NTNBaseContact * contact,
const FrictionID & id = "linear_slip_weakening",
const MemoryID & memory_id = 0);
virtual ~NTNFricLawLinearSlipWeakening(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// register synchronizedarrays for sync
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
/// dump restart file
virtual void dumpRestart(const std::string & file_name) const;
/// read restart file
virtual void readRestart(const std::string & file_name);
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// compute frictional strength according to friction law
virtual void computeFrictionalStrength();
/// computes the friction coefficient as a function of slip
virtual void computeFrictionCoefficient();
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
// static coefficient of friction
SynchronizedArray<Real> mu_s;
// kinetic coefficient of friction
SynchronizedArray<Real> mu_k;
// Dc the length over which slip weakening happens
SynchronizedArray<Real> d_c;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template <class Regularisation>
inline std::ostream &
operator<<(std::ostream & stream,
const NTNFricLawLinearSlipWeakening<Regularisation> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "ntn_friclaw_linear_slip_weakening_tmpl.hh"
#endif /* __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing.hh
index aa69eb866..9711597b5 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing.hh
@@ -1,81 +1,96 @@
/**
* @file ntn_friclaw_linear_slip_weakening_no_healing.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief linear slip weakening
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_NO_HEALING_HH__
#define __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_NO_HEALING_HH__
/* -------------------------------------------------------------------------- */
#include "ntn_friclaw_linear_slip_weakening.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation = NTNFricRegNoRegularisation>
class NTNFricLawLinearSlipWeakeningNoHealing
: public NTNFricLawLinearSlipWeakening<Regularisation> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricLawLinearSlipWeakeningNoHealing(
NTNBaseContact * contact,
const FrictionID & id = "linear_slip_weakening_no_healing",
const MemoryID & memory_id = 0);
virtual ~NTNFricLawLinearSlipWeakeningNoHealing(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// computes the friction coefficient as a function of slip
virtual void computeFrictionCoefficient();
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template <class Regularisation>
inline std::ostream & operator<<(
std::ostream & stream,
const NTNFricLawLinearSlipWeakeningNoHealing<Regularisation> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh"
#endif /* __AST_NTN_FRICLAW_LINEAR_SLIP_WEAKENING_NO_HEALING_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
index bf5e2b241..a58a7d954 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
@@ -1,72 +1,87 @@
/**
* @file ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of linear slip weakening
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawLinearSlipWeakeningNoHealing<Regularisation>::
NTNFricLawLinearSlipWeakeningNoHealing(NTNBaseContact * contact,
const FrictionID & id,
const MemoryID & memory_id)
: NTNFricLawLinearSlipWeakening<Regularisation>(contact, id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakeningNoHealing<
Regularisation>::computeFrictionCoefficient() {
AKANTU_DEBUG_IN();
// get arrays
const SynchronizedArray<Real> & slip = this->internalGetCumulativeSlip();
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
if (slip(n) >= this->d_c(n)) {
this->mu(n) = this->mu_k(n);
} else {
// mu = mu_k + (1 - slip / Dc) * (mu_s - mu_k)
this->mu(n) =
this->mu_k(n) +
(1 - (slip(n) / this->d_c(n))) * (this->mu_s(n) - this->mu_k(n));
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakeningNoHealing<Regularisation>::printself(
std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFricLawLinearSlipWeakeningNoHealing [" << std::endl;
NTNFricLawLinearSlipWeakening<Regularisation>::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh
index d69db957f..f54a6c269 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh
@@ -1,176 +1,191 @@
/**
* @file ntn_friclaw_linear_slip_weakening_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of linear slip weakening
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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 "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawLinearSlipWeakening<Regularisation>::NTNFricLawLinearSlipWeakening(
NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id)
: NTNFricLawCoulomb<Regularisation>(contact, id, memory_id),
mu_s(0, 1, 0., id + ":mu_s", 0., "mu_s"),
mu_k(0, 1, 0., id + ":mu_k", 0., "mu_k"),
d_c(0, 1, 0., id + ":d_c", 0., "d_c") {
AKANTU_DEBUG_IN();
NTNFricLawCoulomb<Regularisation>::registerSynchronizedArray(this->mu_s);
NTNFricLawCoulomb<Regularisation>::registerSynchronizedArray(this->mu_k);
NTNFricLawCoulomb<Regularisation>::registerSynchronizedArray(this->d_c);
this->registerParam("mu_s", this->mu_s, _pat_parsmod,
"static friction coefficient");
this->registerParam("mu_k", this->mu_k, _pat_parsmod,
"kinetic friction coefficient");
this->registerParam("d_c", this->d_c, _pat_parsmod, "slip weakening length");
this->setParamAccessType("mu", _pat_readable);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<
Regularisation>::computeFrictionalStrength() {
AKANTU_DEBUG_IN();
computeFrictionCoefficient();
NTNFricLawCoulomb<Regularisation>::computeFrictionalStrength();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<
Regularisation>::computeFrictionCoefficient() {
AKANTU_DEBUG_IN();
// get arrays
const SynchronizedArray<bool> & stick = this->internalGetIsSticking();
const SynchronizedArray<Real> & slip = this->internalGetSlip();
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
if (stick(n)) {
this->mu(n) = this->mu_s(n);
} else {
if (slip(n) >= this->d_c(n)) {
this->mu(n) = this->mu_k(n);
} else {
// mu = mu_k + (1 - slip / Dc) * (mu_s - mu_k)
this->mu(n) =
this->mu_k(n) +
(1 - (slip(n) / this->d_c(n))) * (this->mu_s(n) - this->mu_k(n));
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->mu_s.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::dumpRestart(
const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->mu_s.dumpRestartFile(file_name);
this->mu_k.dumpRestartFile(file_name);
this->d_c.dumpRestartFile(file_name);
NTNFricLawCoulomb<Regularisation>::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::readRestart(
const std::string & file_name) {
AKANTU_DEBUG_IN();
this->mu_s.readRestartFile(file_name);
this->mu_k.readRestartFile(file_name);
this->d_c.readRestartFile(file_name);
NTNFricLawCoulomb<Regularisation>::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::printself(
std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFricLawLinearSlipWeakening [" << std::endl;
NTNFricLawCoulomb<Regularisation>::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact->getSlaves());
if (field_id == "mu_s") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->mu_s.getArray()));
} else if (field_id == "mu_k") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->mu_k.getArray()));
} else if (field_id == "d_c") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->d_c.getArray()));
} else {
NTNFricLawCoulomb<Regularisation>::addDumpFieldToDumper(dumper_name,
field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc
index 099b31d4d..60a69dd3b 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc
@@ -1,153 +1,168 @@
/**
* @file ntn_fricreg_no_regularisation.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of no regularisation
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_no_regularisation.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNFricRegNoRegularisation::NTNFricRegNoRegularisation(
NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id)
: NTNBaseFriction(contact, id, memory_id),
frictional_contact_pressure(0, 1, 0., id + ":frictional_contact_pressure",
0., "frictional_contact_pressure") {
AKANTU_DEBUG_IN();
NTNBaseFriction::registerSynchronizedArray(this->frictional_contact_pressure);
this->registerParam("frictional_contact_pressure",
this->frictional_contact_pressure, _pat_internal,
"contact pressure used for friction law");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
const SynchronizedArray<Real> &
NTNFricRegNoRegularisation::internalGetContactPressure() {
AKANTU_DEBUG_IN();
this->computeFrictionalContactPressure();
AKANTU_DEBUG_OUT();
return this->frictional_contact_pressure;
}
/* -------------------------------------------------------------------------- */
void NTNFricRegNoRegularisation::computeFrictionalContactPressure() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact->getModel();
UInt dim = model.getSpatialDimension();
// get contact arrays
const SynchronizedArray<bool> & is_in_contact =
this->internalGetIsInContact();
const Array<Real> & pressure = this->contact->getContactPressure().getArray();
Array<Real>::const_iterator<Vector<Real>> it = pressure.begin(dim);
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
this->frictional_contact_pressure(n) = 0.;
// node pair is in contact
else {
// compute frictional contact pressure
const Vector<Real> & pres = it[n];
this->frictional_contact_pressure(n) = pres.norm();
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegNoRegularisation::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->frictional_contact_pressure.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegNoRegularisation::dumpRestart(
const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->frictional_contact_pressure.dumpRestartFile(file_name);
NTNBaseFriction::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegNoRegularisation::readRestart(const std::string & file_name) {
AKANTU_DEBUG_IN();
this->frictional_contact_pressure.readRestartFile(file_name);
NTNBaseFriction::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegNoRegularisation::printself(std::ostream & stream,
int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFricRegNoRegularisation [" << std::endl;
NTNBaseFriction::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegNoRegularisation::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact->getSlaves());
if (field_id == "frictional_contact_pressure") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(
this->frictional_contact_pressure.getArray()));
} else {
NTNBaseFriction::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh
index 3e1d66e0f..8bf0f4173 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.hh
@@ -1,119 +1,134 @@
/**
* @file ntn_fricreg_no_regularisation.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief regularisation that does nothing
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICREG_NO_REGULARISATION_HH__
#define __AST_NTN_FRICREG_NO_REGULARISATION_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_friction.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class NTNFricRegNoRegularisation : public NTNBaseFriction {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricRegNoRegularisation(NTNBaseContact * contact,
const FrictionID & id = "no_regularisation",
const MemoryID & memory_id = 0);
virtual ~NTNFricRegNoRegularisation(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// set to steady state for no regularisation -> do nothing
virtual void setToSteadyState(){};
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
virtual void dumpRestart(const std::string & file_name) const;
virtual void readRestart(const std::string & file_name);
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
virtual void computeFrictionalContactPressure();
/// compute frictional strength according to friction law
virtual void computeFrictionalStrength(){};
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
protected:
/// get the is_in_contact array
virtual const SynchronizedArray<bool> & internalGetIsInContact() {
return this->contact->getIsInContact();
};
/// get the contact pressure (the norm: scalar value)
virtual const SynchronizedArray<Real> & internalGetContactPressure();
/// get the frictional strength array
virtual SynchronizedArray<Real> & internalGetFrictionalStrength() {
return this->frictional_strength;
};
/// get the is_sticking array
virtual SynchronizedArray<bool> & internalGetIsSticking() {
return this->is_sticking;
}
/// get the slip array
virtual SynchronizedArray<Real> & internalGetSlip() { return this->slip; }
/// get the slip array
virtual SynchronizedArray<Real> & internalGetCumulativeSlip() {
return this->cumulative_slip;
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
// contact pressure (absolut value) for computation of friction
SynchronizedArray<Real> frictional_contact_pressure;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "ntn_fricreg_no_regularisation_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const NTNFricRegNoRegularisation & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_NTN_FRICREG_NO_REGULARISATION_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc
index 10496dd03..20a82af49 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc
@@ -1,161 +1,176 @@
/**
* @file ntn_fricreg_rubin_ampuero.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of no regularisation
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_rubin_ampuero.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNFricRegRubinAmpuero::NTNFricRegRubinAmpuero(NTNBaseContact * contact,
const FrictionID & id,
const MemoryID & memory_id)
: NTNFricRegNoRegularisation(contact, id, memory_id),
t_star(0, 1, 0., id + ":t_star", 0., "t_star") {
AKANTU_DEBUG_IN();
NTNFricRegNoRegularisation::registerSynchronizedArray(this->t_star);
this->registerParam("t_star", this->t_star, _pat_parsmod,
"time scale of regularization");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
const SynchronizedArray<Real> &
NTNFricRegRubinAmpuero::internalGetContactPressure() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact->getModel();
UInt dim = model.getSpatialDimension();
Real delta_t = model.getTimeStep();
// get contact arrays
const SynchronizedArray<bool> & is_in_contact =
this->internalGetIsInContact();
const Array<Real> & pressure = this->contact->getContactPressure().getArray();
Array<Real>::const_iterator<Vector<Real>> it = pressure.begin(dim);
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
this->frictional_contact_pressure(n) = 0.;
// if t_star is too small compute like Coulomb friction (without
// regularization)
else if (Math::are_float_equal(this->t_star(n), 0.)) {
const Vector<Real> & pres = it[n];
this->frictional_contact_pressure(n) = pres.norm();
}
else {
// compute frictional contact pressure
// backward euler method: first order implicit numerical integration
// method
// \reg_pres_n+1 = (\reg_pres_n + \delta_t / \t_star * \cur_pres)
// / (1 + \delta_t / \t_star)
Real alpha = delta_t / this->t_star(n);
const Vector<Real> & pres = it[n];
this->frictional_contact_pressure(n) += alpha * pres.norm();
this->frictional_contact_pressure(n) /= 1 + alpha;
}
}
AKANTU_DEBUG_OUT();
return this->frictional_contact_pressure;
}
/* -------------------------------------------------------------------------- */
void NTNFricRegRubinAmpuero::setToSteadyState() {
AKANTU_DEBUG_IN();
NTNFricRegNoRegularisation::computeFrictionalContactPressure();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegRubinAmpuero::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->t_star.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegRubinAmpuero::dumpRestart(const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->t_star.dumpRestartFile(file_name);
NTNFricRegNoRegularisation::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegRubinAmpuero::readRestart(const std::string & file_name) {
AKANTU_DEBUG_IN();
this->t_star.readRestartFile(file_name);
NTNFricRegNoRegularisation::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegRubinAmpuero::printself(std::ostream & stream,
int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFricRegRubinAmpuero [" << std::endl;
NTNFricRegNoRegularisation::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegRubinAmpuero::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact->getSlaves());
if (field_id == "t_star") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->t_star.getArray()));
} else {
NTNFricRegNoRegularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh
index 1ec87e1b6..371473983 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.hh
@@ -1,87 +1,102 @@
/**
* @file ntn_fricreg_rubin_ampuero.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief regularisation that regularizes the contact pressure
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICREG_RUBIN_AMPUERO_HH__
#define __AST_NTN_FRICREG_RUBIN_AMPUERO_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_no_regularisation.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class NTNFricRegRubinAmpuero : public NTNFricRegNoRegularisation {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricRegRubinAmpuero(NTNBaseContact * contact,
const FrictionID & id = "rubin_ampuero",
const MemoryID & memory_id = 0);
virtual ~NTNFricRegRubinAmpuero(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
virtual void dumpRestart(const std::string & file_name) const;
virtual void readRestart(const std::string & file_name);
virtual void setToSteadyState();
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
protected:
/// get the contact pressure (the norm: scalar value)
virtual const SynchronizedArray<Real> & internalGetContactPressure();
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
SynchronizedArray<Real> t_star;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "ntn_fricreg_rubin_ampuero_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const NTNFricRegRubinAmpuero & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_NTN_FRICREG_RUBIN_AMPUERO_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc
index c81b72309..0c4bff531 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc
@@ -1,148 +1,163 @@
/**
* @file ntn_fricreg_simplified_prakash_clifton.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of simplified prakash clifton with one parameter
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_simplified_prakash_clifton.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNFricRegSimplifiedPrakashClifton::NTNFricRegSimplifiedPrakashClifton(
NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id)
: NTNFricRegNoRegularisation(contact, id, memory_id),
t_star(0, 1, 0., id + ":t_star", 0., "t_star"),
spc_internal(0, 1, 0., id + ":spc_internal", 0., "spc_internal") {
AKANTU_DEBUG_IN();
NTNFricRegNoRegularisation::registerSynchronizedArray(this->t_star);
NTNFricRegNoRegularisation::registerSynchronizedArray(this->spc_internal);
this->registerParam("t_star", this->t_star, _pat_parsmod,
"time scale of regularisation");
this->registerParam("spc_internal", this->spc_internal, _pat_internal, "");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegSimplifiedPrakashClifton::computeFrictionalStrength() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact->getModel();
Real delta_t = model.getTimeStep();
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
Real alpha = delta_t / this->t_star(n);
this->frictional_strength(n) += alpha * this->spc_internal(n);
this->frictional_strength(n) /= 1 + alpha;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegSimplifiedPrakashClifton::setToSteadyState() {
AKANTU_DEBUG_IN();
/// fill the spc_internal array
computeFrictionalStrength();
/// set strength without regularisation
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
this->frictional_strength(n) = this->spc_internal(n);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegSimplifiedPrakashClifton::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->t_star.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegSimplifiedPrakashClifton::dumpRestart(
const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->t_star.dumpRestartFile(file_name);
this->spc_internal.dumpRestartFile(file_name);
NTNFricRegNoRegularisation::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegSimplifiedPrakashClifton::readRestart(
const std::string & file_name) {
AKANTU_DEBUG_IN();
this->t_star.readRestartFile(file_name);
this->spc_internal.readRestartFile(file_name);
NTNFricRegNoRegularisation::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegSimplifiedPrakashClifton::printself(std::ostream & stream,
int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFricRegSimplifiedPrakashClifton [" << std::endl;
NTNFricRegNoRegularisation::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNFricRegSimplifiedPrakashClifton::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact->getSlaves());
if (field_id == "t_star") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->t_star.getArray()));
} else {
NTNFricRegNoRegularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh
index 211fd1980..b84fd0fe3 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh
@@ -1,99 +1,114 @@
/**
* @file ntn_fricreg_simplified_prakash_clifton.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief regularisation that regularizes the frictional strength with one
* parameter
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__
#define __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_no_regularisation.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class NTNFricRegSimplifiedPrakashClifton : public NTNFricRegNoRegularisation {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricRegSimplifiedPrakashClifton(
NTNBaseContact * contact,
const FrictionID & id = "simplified_prakash_clifton",
const MemoryID & memory_id = 0);
virtual ~NTNFricRegSimplifiedPrakashClifton(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
virtual void dumpRestart(const std::string & file_name) const;
virtual void readRestart(const std::string & file_name);
virtual void setToSteadyState();
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// compute frictional strength according to friction law
virtual void computeFrictionalStrength();
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
protected:
/// get the frictional strength array
virtual SynchronizedArray<Real> & internalGetFrictionalStrength() {
return this->spc_internal;
};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
SynchronizedArray<Real> t_star;
// to get the incremental frictional strength
SynchronizedArray<Real> spc_internal;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "ntn_fricreg_simplified_prakash_clifton_inline_impl.cc"
/// standard output stream operator
inline std::ostream &
operator<<(std::ostream & stream,
const NTNFricRegSimplifiedPrakashClifton & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc
index 87cb89244..e3608ce3a 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc
@@ -1,105 +1,120 @@
/**
* @file mIIasym_contact.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "mIIasym_contact.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
MIIASYMContact::MIIASYMContact(SolidMechanicsModel & model,
const ContactID & id, const MemoryID & memory_id)
: NTRFContact(model, id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::updateImpedance() {
AKANTU_DEBUG_IN();
NTRFContact::updateImpedance();
- for (UInt i = 0; i < this->impedance.getSize(); ++i) {
+ for (UInt i = 0; i < this->impedance.size(); ++i) {
this->impedance(i) *= 0.5;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/// WARNING: this is only valid for the acceleration in equilibrium
void MIIASYMContact::computeRelativeNormalField(
const Array<Real> & field, Array<Real> & rel_normal_field) const {
AKANTU_DEBUG_IN();
NTRFContact::computeRelativeNormalField(field, rel_normal_field);
for (auto it_rtfield = rel_normal_field.begin();
it_rtfield != rel_normal_field.end(); ++it_rtfield) {
// in the anti-symmetric case
*it_rtfield *= 2.;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::computeRelativeTangentialField(
const Array<Real> & field, Array<Real> & rel_tang_field) const {
AKANTU_DEBUG_IN();
NTRFContact::computeRelativeTangentialField(field, rel_tang_field);
UInt dim = this->model.getSpatialDimension();
for (Array<Real>::iterator<Vector<Real>> it_rtfield =
rel_tang_field.begin(dim);
it_rtfield != rel_tang_field.end(dim); ++it_rtfield) {
// in the anti-symmetric case, the tangential fields become twice as large
*it_rtfield *= 2.;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::computeContactPressureInEquilibrium() {
AKANTU_DEBUG_IN();
NTRFContact::computeContactPressure();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::printself(std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "MIIASYMContact [" << std::endl;
NTRFContact::printself(stream, indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.hh
index 94b55bd91..b2f8685ff 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.hh
@@ -1,76 +1,91 @@
/**
* @file mIIasym_contact.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief contact for mode II anti-symmetric simulations
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_MIIASYM_CONTACT_HH__
#define __AST_MIIASYM_CONTACT_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntrf_contact.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class MIIASYMContact : public NTRFContact {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MIIASYMContact(SolidMechanicsModel & model, const ContactID & id = "contact",
const MemoryID & memory_id = 0);
virtual ~MIIASYMContact(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// update the impedance matrix
virtual void updateImpedance();
/// compute contact pressure -> do nothing because can only compute it in
/// equilibrium
virtual void computeContactPressure(){};
/// compute relative normal field (only value that has to be multiplied with
/// the normal)
/// WARNING: this is only valid for the acceleration in equilibrium
virtual void computeRelativeNormalField(const Array<Real> & field,
Array<Real> & rel_normal_field) const;
/// compute relative tangential field (complet array)
/// relative to master nodes
virtual void
computeRelativeTangentialField(const Array<Real> & field,
Array<Real> & rel_tang_field) const;
/// compute contact pressure that is used over the entire time
virtual void computeContactPressureInEquilibrium();
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
};
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const MIIASYMContact & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_MIIASYM_CONTACT_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc
index 840597b5b..20b1eb424 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc
@@ -1,544 +1,551 @@
/**
* @file ntn_base_contact.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of ntn base contact
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
-// simtools
#include "ntn_base_contact.hh"
#include "dumpable_inline_impl.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
+#include "element_synchronizer.hh"
+#include "mesh_utils.hh"
+/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
-NTNContactSynchElementFilter::NTNContactSynchElementFilter(
- NTNBaseContact * contact)
- : contact(contact),
- connectivity(contact->getModel().getMesh().getConnectivities()) {
- AKANTU_DEBUG_IN();
+// NTNContactSynchElementFilter::NTNContactSynchElementFilter(
+// NTNBaseContact * contact)
+// : contact(contact),
+// connectivity(contact->getModel().getMesh().getConnectivities()) {
+// AKANTU_DEBUG_IN();
- AKANTU_DEBUG_OUT();
-}
+// AKANTU_DEBUG_OUT();
+// }
/* -------------------------------------------------------------------------- */
-bool NTNContactSynchElementFilter::operator()(const Element & e) {
- AKANTU_DEBUG_IN();
-
- ElementType type = e.type;
- UInt element = e.element;
- GhostType ghost_type = e.ghost_type;
-
- // loop over all nodes of this element
- bool need_element = false;
- UInt nb_nodes = Mesh::getNbNodesPerElement(type);
- for (UInt n = 0; n < nb_nodes; ++n) {
- UInt nn = this->connectivity(type, ghost_type)(element, n);
-
- // if one nodes is in this contact, we need this element
- if (this->contact->getNodeIndex(nn) >= 0) {
- need_element = true;
- break;
- }
- }
-
- AKANTU_DEBUG_OUT();
- return need_element;
-}
+// bool NTNContactSynchElementFilter::operator()(const Element & e) {
+// AKANTU_DEBUG_IN();
+
+// ElementType type = e.type;
+// UInt element = e.element;
+// GhostType ghost_type = e.ghost_type;
+
+// // loop over all nodes of this element
+// bool need_element = false;
+// UInt nb_nodes = Mesh::getNbNodesPerElement(type);
+// for (UInt n = 0; n < nb_nodes; ++n) {
+// UInt nn = this->connectivity(type, ghost_type)(element, n);
+
+// // if one nodes is in this contact, we need this element
+// if (this->contact->getNodeIndex(nn) >= 0) {
+// need_element = true;
+// break;
+// }
+// }
+
+// AKANTU_DEBUG_OUT();
+// return need_element;
+// }
/* -------------------------------------------------------------------------- */
-NTNBaseContact::NTNBaseContact(SolidMechanicsModel & model,
- const ContactID & id, const MemoryID & memory_id)
+NTNBaseContact::NTNBaseContact(SolidMechanicsModel & model, const ID & id,
+ const MemoryID & memory_id)
: Memory(id, memory_id), Dumpable(), model(model),
slaves(0, 1, 0, id + ":slaves", std::numeric_limits<UInt>::quiet_NaN(),
"slaves"),
normals(0, model.getSpatialDimension(), 0, id + ":normals",
std::numeric_limits<Real>::quiet_NaN(), "normals"),
contact_pressure(
0, model.getSpatialDimension(), 0, id + ":contact_pressure",
std::numeric_limits<Real>::quiet_NaN(), "contact_pressure"),
is_in_contact(0, 1, false, id + ":is_in_contact", false, "is_in_contact"),
lumped_boundary_slaves(0, 1, 0, id + ":lumped_boundary_slaves",
std::numeric_limits<Real>::quiet_NaN(),
"lumped_boundary_slaves"),
impedance(0, 1, 0, id + ":impedance",
std::numeric_limits<Real>::quiet_NaN(), "impedance"),
contact_surfaces(), slave_elements("slave_elements", id, memory_id),
- node_to_elements(), synch_registry(NULL) {
+ node_to_elements() {
AKANTU_DEBUG_IN();
FEEngine & boundary_fem = this->model.getFEEngineBoundary();
for (ghost_type_t::iterator gt = ghost_type_t::begin();
gt != ghost_type_t::end(); ++gt) {
boundary_fem.initShapeFunctions(*gt);
}
Mesh & mesh = this->model.getMesh();
UInt spatial_dimension = this->model.getSpatialDimension();
- mesh.initElementTypeMapArray(this->slave_elements, 1, spatial_dimension - 1);
+ this->slave_elements.initialize(mesh,
+ _spatial_dimension = spatial_dimension - 1);
MeshUtils::buildNode2Elements(mesh, this->node_to_elements,
spatial_dimension - 1);
this->registerDumper<DumperText>("text_all", id, true);
this->addDumpFilteredMesh(mesh, slave_elements, slaves.getArray(),
spatial_dimension - 1, _not_ghost, _ek_regular);
// parallelisation
- this->synch_registry = new SynchronizerRegistry(*this);
+ this->synch_registry = std::make_unique<SynchronizerRegistry>();
+ this->synch_registry->registerDataAccessor(*this);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
-NTNBaseContact::~NTNBaseContact() {
- AKANTU_DEBUG_IN();
-
- if (this->synch_registry)
- delete this->synch_registry;
-
- if (this->synchronizer)
- delete this->synchronizer;
-
- AKANTU_DEBUG_OUT();
-}
+NTNBaseContact::~NTNBaseContact() = default;
/* -------------------------------------------------------------------------- */
void NTNBaseContact::initParallel() {
AKANTU_DEBUG_IN();
- NTNContactSynchElementFilter elem_filter(this);
- this->synchronizer = FilteredSynchronizer::createFilteredSynchronizer(
- this->model.getSynchronizer(), elem_filter);
+ this->synchronizer = std::make_unique<ElementSynchronizer>(
+ this->model.getMesh().getElementSynchronizer());
+
+ this->synchronizer->filterScheme([&](auto && element) {
+ // loop over all nodes of this element
+ Vector<UInt> conn = const_cast<const Mesh &>(this->model.getMesh())
+ .getConnectivity(element);
+ for (auto & node : conn) {
+ // if one nodes is in this contact, we need this element
+ if (this->getNodeIndex(node) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ });
this->synch_registry->registerSynchronizer(*(this->synchronizer),
_gst_cf_nodal);
this->synch_registry->registerSynchronizer(*(this->synchronizer),
_gst_cf_incr);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::findBoundaryElements(
const Array<UInt> & interface_nodes, ElementTypeMapArray<UInt> & elements) {
AKANTU_DEBUG_IN();
- UInt nb_interface_nodes = interface_nodes.getSize();
- const ElementTypeMapArray<UInt> & connectivity =
- this->model.getMesh().getConnectivities();
-
// add connected boundary elements that have all nodes on this contact
- for (UInt i = 0; i < nb_interface_nodes; ++i) {
- UInt node = interface_nodes(i);
-
- CSR<Element>::iterator it = this->node_to_elements.begin(node);
- CSR<Element>::iterator it_e = this->node_to_elements.end(node);
- for (; it != it_e; ++it) { // loop over all elements connected to node
- ElementType type = it->type;
- UInt element = it->element;
- GhostType ghost_type = it->ghost_type;
-
- UInt nb_nodes = Mesh::getNbNodesPerElement(type);
- UInt nb_found_nodes = 0;
- for (UInt n = 0; n < nb_nodes; ++n) {
- UInt nn = connectivity(type, ghost_type)(element, n);
- if (interface_nodes.find(nn) >= 0)
+ for (const auto & node : interface_nodes) {
+ for (const auto & element : this->node_to_elements.getRow(node)) {
+ Vector<UInt> conn = const_cast<const Mesh &>(this->model.getMesh())
+ .getConnectivity(element);
+ auto nb_nodes = conn.size();
+ decltype(nb_nodes) nb_found_nodes = 0;
+
+ for (auto & nn : conn) {
+ if (interface_nodes.find(nn) != UInt(-1)) {
nb_found_nodes++;
- else
+ } else {
break;
+ }
}
// this is an element between all contact nodes
// and is not already in the elements
if ((nb_found_nodes == nb_nodes) &&
- (elements(type, ghost_type).find(element) < 0)) {
- elements(type, ghost_type).push_back(element);
+ (elements(element.type, element.ghost_type).find(element.element) ==
+ UInt(-1))) {
+ elements(element.type, element.ghost_type).push_back(element.element);
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::addSplitNode(UInt node) {
AKANTU_DEBUG_IN();
UInt dim = this->model.getSpatialDimension();
// add to node arrays
this->slaves.push_back(node);
// set contact as false
this->is_in_contact.push_back(false);
// before initializing
// set contact pressure, normal, lumped_boundary to Nan
this->contact_pressure.push_back(std::numeric_limits<Real>::quiet_NaN());
this->impedance.push_back(std::numeric_limits<Real>::quiet_NaN());
this->lumped_boundary_slaves.push_back(
std::numeric_limits<Real>::quiet_NaN());
- Real nan_normal[dim];
- for (UInt d = 0; d < dim; ++d)
- nan_normal[d] = std::numeric_limits<Real>::quiet_NaN();
+ Vector<Real> nan_normal(dim, std::numeric_limits<Real>::quiet_NaN());
this->normals.push_back(nan_normal);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::registerSynchronizedArray(SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->slaves.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::dumpRestart(const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->slaves.dumpRestartFile(file_name);
this->normals.dumpRestartFile(file_name);
this->is_in_contact.dumpRestartFile(file_name);
this->contact_pressure.dumpRestartFile(file_name);
this->lumped_boundary_slaves.dumpRestartFile(file_name);
this->impedance.dumpRestartFile(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::readRestart(const std::string & file_name) {
AKANTU_DEBUG_IN();
this->slaves.readRestartFile(file_name);
this->normals.readRestartFile(file_name);
this->is_in_contact.readRestartFile(file_name);
this->contact_pressure.readRestartFile(file_name);
this->lumped_boundary_slaves.readRestartFile(file_name);
this->impedance.readRestartFile(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
UInt NTNBaseContact::getNbNodesInContact() const {
AKANTU_DEBUG_IN();
UInt nb_contact = 0;
UInt nb_nodes = this->getNbContactNodes();
const Mesh & mesh = this->model.getMesh();
for (UInt n = 0; n < nb_nodes; ++n) {
bool is_local_node = mesh.isLocalOrMasterNode(this->slaves(n));
bool is_pbc_slave_node = this->model.isPBCSlaveNode(this->slaves(n));
if (is_local_node && !is_pbc_slave_node && this->is_in_contact(n)) {
nb_contact++;
}
}
- StaticCommunicator::getStaticCommunicator().allReduce(&nb_contact, 1,
- _so_sum);
+ mesh.getCommunicator().allReduce(nb_contact, SynchronizerOperation::_sum);
AKANTU_DEBUG_OUT();
return nb_contact;
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::updateInternalData() {
AKANTU_DEBUG_IN();
updateNormals();
updateLumpedBoundary();
updateImpedance();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::updateLumpedBoundary() {
AKANTU_DEBUG_IN();
this->internalUpdateLumpedBoundary(this->slaves.getArray(),
this->slave_elements,
this->lumped_boundary_slaves);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::internalUpdateLumpedBoundary(
const Array<UInt> & nodes, const ElementTypeMapArray<UInt> & elements,
SynchronizedArray<Real> & boundary) {
AKANTU_DEBUG_IN();
// set all values in lumped_boundary to zero
boundary.clear();
UInt dim = this->model.getSpatialDimension();
// UInt nb_contact_nodes = getNbContactNodes();
const FEEngine & boundary_fem = this->model.getFEEngineBoundary();
const Mesh & mesh = this->model.getMesh();
for (ghost_type_t::iterator gt = ghost_type_t::begin();
gt != ghost_type_t::end(); ++gt) {
Mesh::type_iterator it = mesh.firstType(dim - 1, *gt);
Mesh::type_iterator last = mesh.lastType(dim - 1, *gt);
for (; it != last; ++it) {
UInt nb_elements = mesh.getNbElement(*it, *gt);
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(*it);
const Array<UInt> & connectivity = mesh.getConnectivity(*it, *gt);
// get shapes and compute integral
const Array<Real> & shapes = boundary_fem.getShapes(*it, *gt);
Array<Real> area(nb_elements, nb_nodes_per_element);
boundary_fem.integrate(shapes, area, nb_nodes_per_element, *it, *gt);
if (this->contact_surfaces.size() == 0) {
AKANTU_DEBUG_WARNING(
"No surfaces in ntn base contact."
<< " You have to define the lumped boundary by yourself.");
}
Array<UInt>::const_iterator<UInt> elem_it = (elements)(*it, *gt).begin();
Array<UInt>::const_iterator<UInt> elem_it_end =
(elements)(*it, *gt).end();
// loop over contact nodes
for (; elem_it != elem_it_end; ++elem_it) {
for (UInt q = 0; q < nb_nodes_per_element; ++q) {
UInt node = connectivity(*elem_it, q);
UInt node_index = nodes.find(node);
AKANTU_DEBUG_ASSERT(node_index != UInt(-1),
"Could not find node " << node
<< " in the array!");
Real area_to_add = area(*elem_it, q);
boundary(node_index) += area_to_add;
}
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::computeContactPressure() {
AKANTU_DEBUG_IN();
UInt dim = this->model.getSpatialDimension();
Real delta_t = this->model.getTimeStep();
UInt nb_contact_nodes = getNbContactNodes();
AKANTU_DEBUG_ASSERT(delta_t > 0.,
"Cannot compute contact pressure if no time step is set");
// synchronize data
this->synch_registry->synchronize(_gst_cf_nodal);
// pre-compute the acceleration
// (not increment acceleration, because residual is still Kf)
Array<Real> acceleration(this->model.getMesh().getNbNodes(), dim, 0.);
this->model.solveLumped(acceleration, this->model.getMass(),
- this->model.getResidual(),
+ this->model.getInternalForce(),
this->model.getBlockedDOFs(), this->model.getF_M2A());
// compute relative normal fields of displacement, velocity and acceleration
Array<Real> r_disp(0, 1);
Array<Real> r_velo(0, 1);
Array<Real> r_acce(0, 1);
Array<Real> r_old_acce(0, 1);
computeNormalGap(r_disp);
// computeRelativeNormalField(this->model.getCurrentPosition(), r_disp);
computeRelativeNormalField(this->model.getVelocity(), r_velo);
computeRelativeNormalField(acceleration, r_acce);
computeRelativeNormalField(this->model.getAcceleration(), r_old_acce);
- AKANTU_DEBUG_ASSERT(r_disp.getSize() == nb_contact_nodes,
+ AKANTU_DEBUG_ASSERT(r_disp.size() == nb_contact_nodes,
"computeRelativeNormalField does not give back arrays "
<< "size == nb_contact_nodes. nb_contact_nodes = "
<< nb_contact_nodes
- << " | array size = " << r_disp.getSize());
+ << " | array size = " << r_disp.size());
// compute gap array for all nodes
Array<Real> gap(nb_contact_nodes, 1);
Real * gap_p = gap.storage();
Real * r_disp_p = r_disp.storage();
Real * r_velo_p = r_velo.storage();
Real * r_acce_p = r_acce.storage();
Real * r_old_acce_p = r_old_acce.storage();
for (UInt i = 0; i < nb_contact_nodes; ++i) {
*gap_p = *r_disp_p + delta_t * *r_velo_p + delta_t * delta_t * *r_acce_p -
0.5 * delta_t * delta_t * *r_old_acce_p;
// increment pointers
gap_p++;
r_disp_p++;
r_velo_p++;
r_acce_p++;
r_old_acce_p++;
}
// check if gap is negative -> is in contact
for (UInt n = 0; n < nb_contact_nodes; ++n) {
if (gap(n) <= 0.) {
for (UInt d = 0; d < dim; ++d) {
this->contact_pressure(n, d) =
this->impedance(n) * gap(n) / (2 * delta_t) * this->normals(n, d);
}
this->is_in_contact(n) = true;
} else {
for (UInt d = 0; d < dim; ++d)
this->contact_pressure(n, d) = 0.;
this->is_in_contact(n) = false;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::applyContactPressure() {
AKANTU_DEBUG_IN();
UInt nb_contact_nodes = getNbContactNodes();
UInt dim = this->model.getSpatialDimension();
- Array<Real> & residual = this->model.getResidual();
+ Array<Real> & residual = this->model.getInternalForce();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt slave = this->slaves(n);
for (UInt d = 0; d < dim; ++d) {
// residual(master,d) += this->lumped_boundary(n,0) *
// this->contact_pressure(n,d);
residual(slave, d) -=
this->lumped_boundary_slaves(n) * this->contact_pressure(n, d);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Int NTNBaseContact::getNodeIndex(UInt node) const {
- AKANTU_DEBUG_IN();
-
- AKANTU_DEBUG_OUT();
return this->slaves.find(node);
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::printself(std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNBaseContact [" << std::endl;
stream << space << " + id : " << id << std::endl;
stream << space << " + slaves : " << std::endl;
this->slaves.printself(stream, indent + 2);
stream << space << " + normals : " << std::endl;
this->normals.printself(stream, indent + 2);
stream << space << " + contact_pressure : " << std::endl;
this->contact_pressure.printself(stream, indent + 2);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::syncArrays(SyncChoice sync_choice) {
AKANTU_DEBUG_IN();
this->slaves.syncElements(sync_choice);
this->normals.syncElements(sync_choice);
this->is_in_contact.syncElements(sync_choice);
this->contact_pressure.syncElements(sync_choice);
this->lumped_boundary_slaves.syncElements(sync_choice);
this->impedance.syncElements(sync_choice);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
const Array<UInt> & nodal_filter = this->slaves.getArray();
#define ADD_FIELD(field_id, field, type) \
internalAddDumpFieldToDumper( \
dumper_name, field_id, \
new dumper::NodalField<type, true, Array<type>, Array<UInt>>( \
field, 0, 0, &nodal_filter))
if (field_id == "displacement") {
ADD_FIELD(field_id, this->model.getDisplacement(), Real);
} else if (field_id == "mass") {
ADD_FIELD(field_id, this->model.getMass(), Real);
} else if (field_id == "velocity") {
ADD_FIELD(field_id, this->model.getVelocity(), Real);
} else if (field_id == "acceleration") {
ADD_FIELD(field_id, this->model.getAcceleration(), Real);
- } else if (field_id == "force") {
+ } else if (field_id == "external_force") {
ADD_FIELD(field_id, this->model.getForce(), Real);
- } else if (field_id == "residual") {
- ADD_FIELD(field_id, this->model.getResidual(), Real);
+ } else if (field_id == "internal_force") {
+ ADD_FIELD(field_id, this->model.getInternalForce(), Real);
} else if (field_id == "blocked_dofs") {
ADD_FIELD(field_id, this->model.getBlockedDOFs(), bool);
} else if (field_id == "increment") {
ADD_FIELD(field_id, this->model.getIncrement(), Real);
} else if (field_id == "normal") {
internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->normals.getArray()));
} else if (field_id == "contact_pressure") {
internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->contact_pressure.getArray()));
} else if (field_id == "is_in_contact") {
internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<bool>(this->is_in_contact.getArray()));
} else if (field_id == "lumped_boundary_slave") {
internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->lumped_boundary_slaves.getArray()));
} else if (field_id == "impedance") {
internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->impedance.getArray()));
} else {
std::cerr << "Could not add field '" << field_id
<< "' to the dumper. Just ignored it." << std::endl;
}
#undef ADD_FIELD
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh
index 527986f61..407ab5f73 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh
@@ -1,228 +1,246 @@
/**
* @file ntn_base_contact.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief base contact for ntn and ntrf contact
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_BASE_CONTACT_HH__
#define __AST_NTN_BASE_CONTACT_HH__
/* -------------------------------------------------------------------------- */
// akantu
-#include "filtered_synchronizer.hh"
+#include "aka_csr.hh"
#include "solid_mechanics_model.hh"
// simtools
#include "synchronized_array.hh"
namespace akantu {
class NTNBaseContact;
/* -------------------------------------------------------------------------- */
-class NTNContactSynchElementFilter : public SynchElementFilter {
-public:
- // constructor
- NTNContactSynchElementFilter(NTNBaseContact * contact);
+// class NTNContactSynchElementFilter : public SynchElementFilter {
+// public:
+// // constructor
+// NTNContactSynchElementFilter(NTNBaseContact * contact);
- // answer to: do we need this element ?
- virtual bool operator()(const Element & e);
+// // answer to: do we need this element ?
+// virtual bool operator()(const Element & e);
-private:
- const NTNBaseContact * contact;
- const ElementTypeMapArray<UInt> & connectivity;
-};
+// private:
+// const NTNBaseContact * contact;
+// const ElementTypeMapArray<UInt> & connectivity;
+// };
/* -------------------------------------------------------------------------- */
-class NTNBaseContact : protected Memory, public DataAccessor, public Dumpable {
+class NTNBaseContact : protected Memory,
+ public DataAccessor<Element>,
+ public Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- NTNBaseContact(SolidMechanicsModel & model, const ContactID & id = "contact",
+ NTNBaseContact(SolidMechanicsModel & model, const ID & id = "contact",
const MemoryID & memory_id = 0);
virtual ~NTNBaseContact();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initializes ntn contact parallel
virtual void initParallel();
/// add split node
virtual void addSplitNode(UInt node);
/// update normals, lumped boundary, and impedance
virtual void updateInternalData();
/// update (compute the normals)
virtual void updateNormals() = 0;
/// update the lumped boundary B matrix
virtual void updateLumpedBoundary();
/// update the impedance matrix
virtual void updateImpedance() = 0;
/// compute the normal contact force
virtual void computeContactPressure();
/// impose the normal contact force
virtual void applyContactPressure();
/// register synchronizedarrays for sync
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
/// dump restart file
virtual void dumpRestart(const std::string & file_name) const;
/// read restart file
virtual void readRestart(const std::string & file_name);
/// compute the normal gap
virtual void computeNormalGap(Array<Real> & gap) const = 0;
/// compute relative normal field (only value that has to be multiplied with
/// the normal)
/// relative to master nodes
virtual void
computeRelativeNormalField(const Array<Real> & field,
Array<Real> & rel_normal_field) const = 0;
/// compute relative tangential field (complet array)
/// relative to master nodes
virtual void
computeRelativeTangentialField(const Array<Real> & field,
Array<Real> & rel_tang_field) const = 0;
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// updateLumpedBoundary
virtual void
internalUpdateLumpedBoundary(const Array<UInt> & nodes,
const ElementTypeMapArray<UInt> & elements,
SynchronizedArray<Real> & boundary);
// to find the slave_elements or master_elements
virtual void findBoundaryElements(const Array<UInt> & interface_nodes,
ElementTypeMapArray<UInt> & elements);
/// synchronize arrays
virtual void syncArrays(SyncChoice sync_choice);
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- inline virtual UInt getNbDataForElements(const Array<Element> & elements,
- SynchronizationTag tag) const;
+ inline UInt getNbData(const Array<Element> & elements,
+ const SynchronizationTag & tag) const override;
- inline virtual void packElementData(CommunicationBuffer & buffer,
- const Array<Element> & elements,
- SynchronizationTag tag) const;
+ inline void packData(CommunicationBuffer & buffer,
+ const Array<Element> & elements,
+ const SynchronizationTag & tag) const override;
- inline virtual void unpackElementData(CommunicationBuffer & buffer,
- const Array<Element> & elements,
- SynchronizationTag tag);
+ inline void unpackData(CommunicationBuffer & buffer,
+ const Array<Element> & elements,
+ const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO(Model, model, SolidMechanicsModel &)
AKANTU_GET_MACRO(Slaves, slaves, const SynchronizedArray<UInt> &)
AKANTU_GET_MACRO(Normals, normals, const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(ContactPressure, contact_pressure,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(LumpedBoundarySlaves, lumped_boundary_slaves,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(Impedance, impedance, const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(IsInContact, is_in_contact, const SynchronizedArray<bool> &)
AKANTU_GET_MACRO(SlaveElements, slave_elements,
const ElementTypeMapArray<UInt> &)
- AKANTU_GET_MACRO(SynchronizerRegistry, synch_registry, SynchronizerRegistry *)
+ AKANTU_GET_MACRO(SynchronizerRegistry, *synch_registry,
+ SynchronizerRegistry &)
/// get number of nodes that are in contact (globally, on all procs together)
/// is_in_contact = true
virtual UInt getNbNodesInContact() const;
/// get index of node in either slaves or masters array
/// if node is in neither of them, return -1
virtual Int getNodeIndex(UInt node) const;
/// get number of contact nodes: nodes in the system locally (on this proc)
/// is_in_contact = true and false, because just in the system
- virtual UInt getNbContactNodes() const { return this->slaves.getSize(); };
+ virtual UInt getNbContactNodes() const { return this->slaves.size(); };
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
typedef std::set<const ElementGroup *> SurfacePtrSet;
SolidMechanicsModel & model;
/// array of slave nodes
SynchronizedArray<UInt> slaves;
/// array of normals
SynchronizedArray<Real> normals;
/// array indicating if nodes are in contact
SynchronizedArray<Real> contact_pressure;
/// array indicating if nodes are in contact
SynchronizedArray<bool> is_in_contact;
/// boundary matrix for slave nodes
SynchronizedArray<Real> lumped_boundary_slaves;
/// impedance matrix
SynchronizedArray<Real> impedance;
/// contact surface
SurfacePtrSet contact_surfaces;
/// element list for dump and lumped_boundary
ElementTypeMapArray<UInt> slave_elements;
CSR<Element> node_to_elements;
/// parallelisation
- SynchronizerRegistry * synch_registry;
- Synchronizer * synchronizer;
+ std::unique_ptr<SynchronizerRegistry> synch_registry;
+ std::unique_ptr<ElementSynchronizer> synchronizer;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "ntn_base_contact_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const NTNBaseContact & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_NTN_BASE_CONTACT_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact_inline_impl.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact_inline_impl.cc
index 276c72199..48ce6b68c 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact_inline_impl.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact_inline_impl.cc
@@ -1,105 +1,119 @@
/**
* @file ntn_base_contact_inline_impl.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief ntn base contact inline functions
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
-inline UInt
-NTNBaseContact::getNbDataForElements(const Array<Element> & elements,
- SynchronizationTag tag) const {
+inline UInt NTNBaseContact::getNbData(const Array<Element> & elements,
+ const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = 0;
UInt spatial_dimension = this->model.getSpatialDimension();
UInt nb_nodes = 0;
Array<Element>::const_iterator<Element> it = elements.begin();
Array<Element>::const_iterator<Element> end = elements.end();
for (; it != end; ++it) {
const Element & el = *it;
nb_nodes += Mesh::getNbNodesPerElement(el.type);
}
switch (tag) {
case _gst_cf_nodal: {
size += nb_nodes * spatial_dimension * sizeof(Real) *
3; // disp, vel and cur_pos
break;
}
case _gst_cf_incr: {
size += nb_nodes * spatial_dimension * sizeof(Real) * 1;
break;
}
default: {}
}
AKANTU_DEBUG_OUT();
return size;
}
/* -------------------------------------------------------------------------- */
-inline void NTNBaseContact::packElementData(CommunicationBuffer & buffer,
- const Array<Element> & elements,
- SynchronizationTag tag) const {
+inline void NTNBaseContact::packData(CommunicationBuffer & buffer,
+ const Array<Element> & elements,
+ const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
switch (tag) {
case _gst_cf_nodal: {
DataAccessor::packNodalDataHelper(this->model.getDisplacement(), buffer,
elements, this->model.getMesh());
DataAccessor::packNodalDataHelper(this->model.getCurrentPosition(), buffer,
elements, this->model.getMesh());
DataAccessor::packNodalDataHelper(this->model.getVelocity(), buffer,
elements, this->model.getMesh());
break;
}
case _gst_cf_incr: {
DataAccessor::packNodalDataHelper(this->model.getIncrement(), buffer,
elements, this->model.getMesh());
break;
}
default: {}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
-inline void NTNBaseContact::unpackElementData(CommunicationBuffer & buffer,
- const Array<Element> & elements,
- SynchronizationTag tag) {
+inline void NTNBaseContact::unpackData(CommunicationBuffer & buffer,
+ const Array<Element> & elements,
+ const SynchronizationTag & tag) {
AKANTU_DEBUG_IN();
switch (tag) {
case _gst_cf_nodal: {
DataAccessor::unpackNodalDataHelper(this->model.getDisplacement(), buffer,
elements, this->model.getMesh());
DataAccessor::unpackNodalDataHelper(
const_cast<Array<Real> &>(this->model.getCurrentPosition()), buffer,
elements, this->model.getMesh());
DataAccessor::unpackNodalDataHelper(this->model.getVelocity(), buffer,
elements, this->model.getMesh());
break;
}
case _gst_cf_incr: {
DataAccessor::unpackNodalDataHelper(this->model.getIncrement(), buffer,
elements, this->model.getMesh());
break;
}
default: {}
}
AKANTU_DEBUG_OUT();
}
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc
index 5609ea3da..df984c08d 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc
@@ -1,367 +1,382 @@
/**
* @file ntn_base_friction.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of ntn base friction
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_friction.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNBaseFriction::NTNBaseFriction(NTNBaseContact * contact,
const FrictionID & id,
const MemoryID & memory_id)
: Memory(id, memory_id), Parsable(_st_friction, id), Dumpable(),
contact(contact),
is_sticking(0, 1, true, id + ":is_sticking", true, "is_sticking"),
frictional_strength(0, 1, 0., id + ":frictional_strength", 0.,
"frictional_strength"),
friction_traction(0, contact->getModel().getSpatialDimension(), 0.,
id + ":friction_traction", 0., "friction_traction"),
slip(0, 1, 0., id + ":slip", 0., "slip"),
cumulative_slip(0, 1, 0., id + ":cumulative_slip", 0., "cumulative_slip"),
slip_velocity(0, contact->getModel().getSpatialDimension(), 0.,
id + ":slip_velocity", 0., "slip_velocity") {
AKANTU_DEBUG_IN();
this->contact->registerSynchronizedArray(this->is_sticking);
this->contact->registerSynchronizedArray(this->frictional_strength);
this->contact->registerSynchronizedArray(this->friction_traction);
this->contact->registerSynchronizedArray(this->slip);
this->contact->registerSynchronizedArray(this->cumulative_slip);
this->contact->registerSynchronizedArray(this->slip_velocity);
contact->getModel().setIncrementFlagOn();
this->registerExternalDumper(contact->getDumper(),
contact->getDefaultDumperName(), true);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::updateSlip() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact->getModel();
UInt dim = model.getSpatialDimension();
// synchronize increment
this->contact->getSynchronizerRegistry()->synchronize(_gst_cf_incr);
Array<Real> rel_tan_incr(0, dim);
this->contact->computeRelativeTangentialField(model.getIncrement(),
rel_tan_incr);
Array<Real>::const_iterator<Vector<Real>> it = rel_tan_incr.begin(dim);
UInt nb_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_nodes; ++n) {
if (this->is_sticking(n)) {
this->slip(n) = 0.;
} else {
const Vector<Real> & rti = it[n];
this->slip(n) += rti.norm();
this->cumulative_slip(n) += rti.norm();
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::computeFrictionTraction() {
AKANTU_DEBUG_IN();
this->computeStickTraction();
this->computeFrictionalStrength();
SolidMechanicsModel & model = this->contact->getModel();
UInt dim = model.getSpatialDimension();
// get contact arrays
const SynchronizedArray<bool> & is_in_contact =
this->contact->getIsInContact();
Array<Real> & traction =
const_cast<Array<Real> &>(this->friction_traction.getArray());
Array<Real>::iterator<Vector<Real>> it_fric_trac = traction.begin(dim);
this->is_sticking.clear(); // set to not sticking
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is in contact
if (is_in_contact(n)) {
Vector<Real> fric_trac = it_fric_trac[n];
// check if it is larger than frictional strength
Real abs_fric = fric_trac.norm();
if (abs_fric != 0.) {
Real alpha = this->frictional_strength(n) / abs_fric;
// larger -> sliding
if (alpha < 1.) {
fric_trac *= alpha;
} else
this->is_sticking(n) = true;
} else {
// frictional traction is already zero
this->is_sticking(n) = true;
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::computeStickTraction() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact->getModel();
UInt dim = model.getSpatialDimension();
Real delta_t = model.getTimeStep();
UInt nb_contact_nodes = this->contact->getNbContactNodes();
// get contact arrays
const SynchronizedArray<Real> & impedance = this->contact->getImpedance();
const SynchronizedArray<bool> & is_in_contact =
this->contact->getIsInContact();
// pre-compute the acceleration
// (not increment acceleration, because residual is still Kf)
Array<Real> acceleration(model.getFEEngine().getMesh().getNbNodes(), dim, 0.);
model.solveLumped(acceleration, model.getMass(), model.getResidual(),
model.getBlockedDOFs(), model.getF_M2A());
// compute relative normal fields of velocity and acceleration
Array<Real> r_velo(0, dim);
Array<Real> r_acce(0, dim);
Array<Real> r_old_acce(0, dim);
this->contact->computeRelativeTangentialField(model.getVelocity(), r_velo);
this->contact->computeRelativeTangentialField(acceleration, r_acce);
this->contact->computeRelativeTangentialField(model.getAcceleration(),
r_old_acce);
- AKANTU_DEBUG_ASSERT(r_velo.getSize() == nb_contact_nodes,
+ AKANTU_DEBUG_ASSERT(r_velo.size() == nb_contact_nodes,
"computeRelativeNormalField does not give back arrays "
<< "size == nb_contact_nodes. nb_contact_nodes = "
<< nb_contact_nodes
- << " | array size = " << r_velo.getSize());
+ << " | array size = " << r_velo.size());
// compute tangential gap_dot array for all nodes
Array<Real> gap_dot(nb_contact_nodes, dim);
Real * gap_dot_p = gap_dot.storage();
Real * r_velo_p = r_velo.storage();
Real * r_acce_p = r_acce.storage();
Real * r_old_acce_p = r_old_acce.storage();
for (UInt i = 0; i < nb_contact_nodes * dim; ++i) {
*gap_dot_p =
*r_velo_p + delta_t * *r_acce_p - 0.5 * delta_t * *r_old_acce_p;
// increment pointers
gap_dot_p++;
r_velo_p++;
r_acce_p++;
r_old_acce_p++;
}
// compute friction traction to stop sliding
Array<Real> & traction =
const_cast<Array<Real> &>(this->friction_traction.getArray());
auto it_fric_trac = traction.begin(dim);
for (UInt n = 0; n < nb_contact_nodes; ++n) {
Vector<Real> fric_trac = it_fric_trac[n];
// node pair is NOT in contact
if (!is_in_contact(n)) {
fric_trac.clear(); // set to zero
}
// node pair is in contact
else {
// compute friction traction
for (UInt d = 0; d < dim; ++d)
fric_trac(d) = impedance(n) * gap_dot(n, d) / 2.;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::applyFrictionTraction() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact->getModel();
Array<Real> & residual = model.getResidual();
UInt dim = model.getSpatialDimension();
const SynchronizedArray<UInt> & slaves = this->contact->getSlaves();
const SynchronizedArray<Real> & lumped_boundary_slaves =
this->contact->getLumpedBoundarySlaves();
UInt nb_contact_nodes = this->contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt slave = slaves(n);
for (UInt d = 0; d < dim; ++d) {
residual(slave, d) -=
lumped_boundary_slaves(n) * this->friction_traction(n, d);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::registerSynchronizedArray(SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->frictional_strength.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::dumpRestart(const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->is_sticking.dumpRestartFile(file_name);
this->frictional_strength.dumpRestartFile(file_name);
this->friction_traction.dumpRestartFile(file_name);
this->slip.dumpRestartFile(file_name);
this->cumulative_slip.dumpRestartFile(file_name);
this->slip_velocity.dumpRestartFile(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::readRestart(const std::string & file_name) {
AKANTU_DEBUG_IN();
this->is_sticking.readRestartFile(file_name);
this->frictional_strength.readRestartFile(file_name);
this->friction_traction.readRestartFile(file_name);
this->cumulative_slip.readRestartFile(file_name);
this->slip_velocity.readRestartFile(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::setParam(const std::string & name, UInt node,
Real value) {
AKANTU_DEBUG_IN();
SynchronizedArray<Real> & array = this->get<SynchronizedArray<Real>>(name);
Int index = this->contact->getNodeIndex(node);
if (index < 0) {
AKANTU_DEBUG_WARNING("Node "
<< node << " is not a contact node. "
<< "Therefore, cannot set interface parameter!!");
} else {
array(index) = value; // put value
}
AKANTU_DEBUG_OUT();
};
/* -------------------------------------------------------------------------- */
UInt NTNBaseFriction::getNbStickingNodes() const {
AKANTU_DEBUG_IN();
UInt nb_stick = 0;
UInt nb_nodes = this->contact->getNbContactNodes();
const SynchronizedArray<UInt> & nodes = this->contact->getSlaves();
const SynchronizedArray<bool> & is_in_contact =
this->contact->getIsInContact();
const Mesh & mesh = this->contact->getModel().getMesh();
for (UInt n = 0; n < nb_nodes; ++n) {
bool is_local_node = mesh.isLocalOrMasterNode(nodes(n));
bool is_pbc_slave_node = this->contact->getModel().isPBCSlaveNode(nodes(n));
if (is_local_node && !is_pbc_slave_node && is_in_contact(n) &&
this->is_sticking(n)) {
nb_stick++;
}
}
StaticCommunicator::getStaticCommunicator().allReduce(&nb_stick, 1, _so_sum);
AKANTU_DEBUG_OUT();
return nb_stick;
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::printself(std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNBaseFriction [" << std::endl;
Parsable::printself(stream, indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact->getSlaves());
if (field_id == "is_sticking") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<bool>(this->is_sticking.getArray()));
} else if (field_id == "frictional_strength") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->frictional_strength.getArray()));
} else if (field_id == "friction_traction") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->friction_traction.getArray()));
} else if (field_id == "slip") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->slip.getArray()));
} else if (field_id == "cumulative_slip") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->cumulative_slip.getArray()));
} else if (field_id == "slip_velocity") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->slip_velocity.getArray()));
} else {
this->contact->addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh
index d5a3d06e5..a2e7ca7ae 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh
@@ -1,162 +1,177 @@
/**
* @file ntn_base_friction.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief base class for ntn and ntrf friction
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_BASE_FRICTION_HH__
#define __AST_NTN_BASE_FRICTION_HH__
/* -------------------------------------------------------------------------- */
// akantu
#include "parsable.hh"
// simtools
#include "ntn_base_contact.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
template <>
inline void ParsableParamTyped<akantu::SynchronizedArray<Real>>::parseParam(
const ParserParameter & in_param) {
ParsableParam::parseParam(in_param);
Real tmp = in_param;
param.setAndChangeDefault(tmp);
}
/* -------------------------------------------------------------------------- */
template <>
template <>
inline void ParsableParamTyped<akantu::SynchronizedArray<Real>>::setTyped<Real>(
const Real & value) {
param.setAndChangeDefault(value);
}
/* -------------------------------------------------------------------------- */
class NTNBaseFriction : protected Memory, public Parsable, public Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNBaseFriction(NTNBaseContact * contact, const FrictionID & id = "friction",
const MemoryID & memory_id = 0);
virtual ~NTNBaseFriction(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// compute friction traction
virtual void computeFrictionTraction();
/// compute stick traction (friction traction needed to stick the nodes)
virtual void computeStickTraction();
/// apply the friction force
virtual void applyFrictionTraction();
/// compute slip
virtual void updateSlip();
/// register Syncronizedarrays for sync
virtual void registerSynchronizedArray(SynchronizedArrayBase & array);
/// dump restart file
virtual void dumpRestart(const std::string & file_name) const;
/// read restart file
virtual void readRestart(const std::string & file_name);
/// set to steady state
virtual void setToSteadyState() { AKANTU_TO_IMPLEMENT(); };
/// get the number of sticking nodes (in parallel)
/// a node that is not in contact does not count as sticking
virtual UInt getNbStickingNodes() const;
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// compute frictional strength according to friction law
virtual void computeFrictionalStrength() = 0;
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO(Contact, contact, const NTNBaseContact *)
AKANTU_GET_MACRO(IsSticking, is_sticking, const SynchronizedArray<bool> &)
AKANTU_GET_MACRO(FrictionalStrength, frictional_strength,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(FrictionTraction, friction_traction,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(Slip, slip, const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(CumulativeSlip, cumulative_slip,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(SlipVelocity, slip_velocity, const SynchronizedArray<Real> &)
/// set parameter of a given node
/// (if you need to set to all: used the setMixed function of the Parsable).
virtual void setParam(const std::string & name, UInt node, Real value);
// replaced by the setMixed of the Parsable
// virtual void setParam(const std::string & param, Real value) {
// AKANTU_ERROR("Friction does not know the following parameter: " <<
// param);
// };
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
NTNBaseContact * contact;
// if node is sticking
SynchronizedArray<bool> is_sticking;
// frictional strength
SynchronizedArray<Real> frictional_strength;
// friction force
SynchronizedArray<Real> friction_traction;
// slip
SynchronizedArray<Real> slip;
SynchronizedArray<Real> cumulative_slip;
// slip velocity (tangential vector)
SynchronizedArray<Real> slip_velocity;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "ntn_base_friction_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const NTNBaseFriction & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_NTN_BASE_FRICTION_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc
index 8af146114..922b6f4c7 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc
@@ -1,575 +1,590 @@
/**
* @file ntn_contact.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of ntn_contact
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_contact.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNContact::NTNContact(SolidMechanicsModel & model, const ContactID & id,
const MemoryID & memory_id)
: NTNBaseContact(model, id, memory_id),
masters(0, 1, 0, id + ":masters", std::numeric_limits<UInt>::quiet_NaN(),
"masters"),
lumped_boundary_masters(0, 1, 0, id + ":lumped_boundary_masters",
std::numeric_limits<Real>::quiet_NaN(),
"lumped_boundary_masters"),
master_elements("master_elements", id, memory_id) {
AKANTU_DEBUG_IN();
const Mesh & mesh = this->model.getMesh();
UInt spatial_dimension = this->model.getSpatialDimension();
mesh.initElementTypeMapArray(this->master_elements, 1, spatial_dimension - 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::pairInterfaceNodes(const ElementGroup & slave_boundary,
const ElementGroup & master_boundary,
UInt surface_normal_dir, const Mesh & mesh,
Array<UInt> & pairs) {
AKANTU_DEBUG_IN();
pairs.resize(0);
AKANTU_DEBUG_ASSERT(pairs.getNbComponent() == 2,
"Array of node pairs should have nb_component = 2,"
<< " but has nb_component = "
<< pairs.getNbComponent());
UInt dim = mesh.getSpatialDimension();
AKANTU_DEBUG_ASSERT(surface_normal_dir < dim,
"Mesh is of " << dim << " dimensions"
<< " and cannot have direction "
<< surface_normal_dir
<< " for surface normal");
// offset for projection computation
UInt offset[dim - 1];
for (UInt i = 0, j = 0; i < dim; ++i) {
if (surface_normal_dir != i) {
offset[j] = i;
++j;
}
}
// find projected node coordinates
const Array<Real> & coordinates = mesh.getNodes();
// find slave nodes
Array<Real> proj_slave_coord(slave_boundary.getNbNodes(), dim - 1, 0.);
Array<UInt> slave_nodes(slave_boundary.getNbNodes());
UInt n(0);
for (ElementGroup::const_node_iterator nodes_it(slave_boundary.node_begin());
nodes_it != slave_boundary.node_end(); ++nodes_it) {
for (UInt d = 0; d < dim - 1; ++d) {
proj_slave_coord(n, d) = coordinates(*nodes_it, offset[d]);
slave_nodes(n) = *nodes_it;
}
++n;
}
// find master nodes
Array<Real> proj_master_coord(master_boundary.getNbNodes(), dim - 1, 0.);
Array<UInt> master_nodes(master_boundary.getNbNodes());
n = 0;
for (ElementGroup::const_node_iterator nodes_it(master_boundary.node_begin());
nodes_it != master_boundary.node_end(); ++nodes_it) {
for (UInt d = 0; d < dim - 1; ++d) {
proj_master_coord(n, d) = coordinates(*nodes_it, offset[d]);
master_nodes(n) = *nodes_it;
}
++n;
}
// find minimum distance between slave nodes to define tolerance
Real min_dist = std::numeric_limits<Real>::max();
- for (UInt i = 0; i < proj_slave_coord.getSize(); ++i) {
- for (UInt j = i + 1; j < proj_slave_coord.getSize(); ++j) {
+ for (UInt i = 0; i < proj_slave_coord.size(); ++i) {
+ for (UInt j = i + 1; j < proj_slave_coord.size(); ++j) {
Real dist = 0.;
for (UInt d = 0; d < dim - 1; ++d) {
dist += (proj_slave_coord(i, d) - proj_slave_coord(j, d)) *
(proj_slave_coord(i, d) - proj_slave_coord(j, d));
}
if (dist < min_dist) {
min_dist = dist;
}
}
}
min_dist = std::sqrt(min_dist);
Real local_tol = 0.1 * min_dist;
// find master slave node pairs
- for (UInt i = 0; i < proj_slave_coord.getSize(); ++i) {
- for (UInt j = 0; j < proj_master_coord.getSize(); ++j) {
+ for (UInt i = 0; i < proj_slave_coord.size(); ++i) {
+ for (UInt j = 0; j < proj_master_coord.size(); ++j) {
Real dist = 0.;
for (UInt d = 0; d < dim - 1; ++d) {
dist += (proj_slave_coord(i, d) - proj_master_coord(j, d)) *
(proj_slave_coord(i, d) - proj_master_coord(j, d));
}
dist = std::sqrt(dist);
if (dist < local_tol) { // it is a pair
UInt pair[2];
pair[0] = slave_nodes(i);
pair[1] = master_nodes(j);
pairs.push_back(pair);
continue; // found master do not need to search further for this slave
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::addSurfacePair(const Surface & slave, const Surface & master,
UInt surface_normal_dir) {
AKANTU_DEBUG_IN();
const Mesh & mesh = this->model.getMesh();
const ElementGroup & slave_boundary = mesh.getElementGroup(slave);
const ElementGroup & master_boundary = mesh.getElementGroup(master);
this->contact_surfaces.insert(&slave_boundary);
this->contact_surfaces.insert(&master_boundary);
Array<UInt> pairs(0, 2);
NTNContact::pairInterfaceNodes(slave_boundary, master_boundary,
surface_normal_dir, this->model.getMesh(),
pairs);
// eliminate pairs which contain a pbc slave node
Array<UInt> pairs_no_PBC_slaves(0, 2);
Array<UInt>::const_vector_iterator it = pairs.begin(2);
Array<UInt>::const_vector_iterator end = pairs.end(2);
for (; it != end; ++it) {
const Vector<UInt> & pair = *it;
if (!this->model.isPBCSlaveNode(pair(0)) &&
!this->model.isPBCSlaveNode(pair(1))) {
pairs_no_PBC_slaves.push_back(pair);
}
}
this->addNodePairs(pairs_no_PBC_slaves);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::addNodePairs(const Array<UInt> & pairs) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(pairs.getNbComponent() == 2,
"Array of node pairs should have nb_component = 2,"
<< " but has nb_component = "
<< pairs.getNbComponent());
- UInt nb_pairs = pairs.getSize();
+ UInt nb_pairs = pairs.size();
for (UInt n = 0; n < nb_pairs; ++n) {
this->addSplitNode(pairs(n, 0), pairs(n, 1));
}
// synchronize with depending nodes
findBoundaryElements(this->slaves.getArray(), this->slave_elements);
findBoundaryElements(this->masters.getArray(), this->master_elements);
updateInternalData();
syncArrays(_added);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::getNodePairs(Array<UInt> & pairs) const {
AKANTU_DEBUG_IN();
pairs.resize(0);
AKANTU_DEBUG_ASSERT(pairs.getNbComponent() == 2,
"Array of node pairs should have nb_component = 2,"
<< " but has nb_component = "
<< pairs.getNbComponent());
UInt nb_pairs = this->getNbContactNodes();
for (UInt n = 0; n < nb_pairs; ++n) {
UInt pair[2];
pair[0] = this->slaves(n);
pair[1] = this->masters(n);
pairs.push_back(pair);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::addSplitNode(UInt slave, UInt master) {
AKANTU_DEBUG_IN();
NTNBaseContact::addSplitNode(slave);
this->masters.push_back(master);
this->lumped_boundary_masters.push_back(
std::numeric_limits<Real>::quiet_NaN());
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/*
This function only works for surface elements with one quad point. For
surface elements with more quad points, it computes still, but the result
might not be what you are looking for.
*/
void NTNContact::updateNormals() {
AKANTU_DEBUG_IN();
// set normals to zero
this->normals.clear();
// contact information
UInt dim = this->model.getSpatialDimension();
UInt nb_contact_nodes = this->getNbContactNodes();
this->synch_registry->synchronize(_gst_cf_nodal); // synchronize current pos
const Array<Real> & cur_pos = this->model.getCurrentPosition();
FEEngine & boundary_fem = this->model.getFEEngineBoundary();
const Mesh & mesh = this->model.getMesh();
for (ghost_type_t::iterator gt = ghost_type_t::begin();
gt != ghost_type_t::end(); ++gt) {
Mesh::type_iterator it = mesh.firstType(dim - 1, *gt);
Mesh::type_iterator last = mesh.lastType(dim - 1, *gt);
for (; it != last; ++it) {
// compute the normals
Array<Real> quad_normals(0, dim);
boundary_fem.computeNormalsOnIntegrationPoints(cur_pos, quad_normals, *it,
*gt);
UInt nb_quad_points = boundary_fem.getNbIntegrationPoints(*it, *gt);
// new version: compute normals only based on master elements (and not all
// boundary elements)
// -------------------------------------------------------------------------------------
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(*it);
const Array<UInt> & connectivity = mesh.getConnectivity(*it, *gt);
Array<UInt>::const_iterator<UInt> elem_it =
(this->master_elements)(*it, *gt).begin();
Array<UInt>::const_iterator<UInt> elem_it_end =
(this->master_elements)(*it, *gt).end();
// loop over contact nodes
for (; elem_it != elem_it_end; ++elem_it) {
for (UInt q = 0; q < nb_nodes_per_element; ++q) {
UInt node = connectivity(*elem_it, q);
UInt node_index = this->masters.find(node);
AKANTU_DEBUG_ASSERT(node_index != UInt(-1),
"Could not find node " << node
<< " in the array!");
for (UInt q = 0; q < nb_quad_points; ++q) {
// add quad normal to master normal
for (UInt d = 0; d < dim; ++d) {
this->normals(node_index, d) +=
quad_normals((*elem_it) * nb_quad_points + q, d);
}
}
}
}
// -------------------------------------------------------------------------------------
/*
// get elements connected to each node
CSR<UInt> node_to_element;
MeshUtils::buildNode2ElementsElementTypeMap(mesh, node_to_element, *it,
*gt);
// add up normals to all master nodes
for (UInt n=0; n<nb_contact_nodes; ++n) {
UInt master = this->masters(n);
CSR<UInt>::iterator elem = node_to_element.begin(master);
// loop over all elements connected to this master node
for (; elem != node_to_element.end(master); ++elem) {
UInt e = *elem;
// loop over all quad points of this element
for (UInt q=0; q<nb_quad_points; ++q) {
// add quad normal to master normal
for (UInt d=0; d<dim; ++d) {
this->normals(n,d) += quad_normals(e*nb_quad_points + q, d);
}
}
}
}
*/
}
}
Real * master_normals = this->normals.storage();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
if (dim == 2)
Math::normalize2(&(master_normals[n * dim]));
else if (dim == 3)
Math::normalize3(&(master_normals[n * dim]));
}
// // normalize normals
// auto nit = this->normals.begin();
// auto nend = this->normals.end();
// for (; nit != nend; ++nit) {
// nit->normalize();
// }
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::dumpRestart(const std::string & file_name) const {
AKANTU_DEBUG_IN();
NTNBaseContact::dumpRestart(file_name);
this->masters.dumpRestartFile(file_name);
this->lumped_boundary_masters.dumpRestartFile(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::readRestart(const std::string & file_name) {
AKANTU_DEBUG_IN();
NTNBaseContact::readRestart(file_name);
this->masters.readRestartFile(file_name);
this->lumped_boundary_masters.readRestartFile(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::updateImpedance() {
AKANTU_DEBUG_IN();
UInt nb_contact_nodes = getNbContactNodes();
Real delta_t = this->model.getTimeStep();
AKANTU_DEBUG_ASSERT(delta_t != NAN,
"Time step is NAN. Have you set it already?");
const Array<Real> & mass = this->model.getMass();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt master = this->masters(n);
UInt slave = this->slaves(n);
Real imp = (this->lumped_boundary_masters(n) / mass(master)) +
(this->lumped_boundary_slaves(n) / mass(slave));
imp = 2 / delta_t / imp;
this->impedance(n) = imp;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::updateLumpedBoundary() {
AKANTU_DEBUG_IN();
internalUpdateLumpedBoundary(this->slaves.getArray(), this->slave_elements,
this->lumped_boundary_slaves);
internalUpdateLumpedBoundary(this->masters.getArray(), this->master_elements,
this->lumped_boundary_masters);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::applyContactPressure() {
AKANTU_DEBUG_IN();
UInt nb_ntn_pairs = getNbContactNodes();
UInt dim = this->model.getSpatialDimension();
Array<Real> & residual = this->model.getResidual();
for (UInt n = 0; n < nb_ntn_pairs; ++n) {
UInt master = this->masters(n);
UInt slave = this->slaves(n);
for (UInt d = 0; d < dim; ++d) {
residual(master, d) +=
this->lumped_boundary_masters(n) * this->contact_pressure(n, d);
residual(slave, d) -=
this->lumped_boundary_slaves(n) * this->contact_pressure(n, d);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::computeRelativeTangentialField(
const Array<Real> & field, Array<Real> & rel_tang_field) const {
AKANTU_DEBUG_IN();
// resize arrays to zero
rel_tang_field.resize(0);
UInt dim = this->model.getSpatialDimension();
auto it_field = field.begin(dim);
auto it_normal = this->normals.getArray().begin(dim);
Vector<Real> rfv(dim);
Vector<Real> np_rfv(dim);
- UInt nb_contact_nodes = this->slaves.getSize();
+ UInt nb_contact_nodes = this->slaves.size();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// nodes
UInt slave = this->slaves(n);
UInt master = this->masters(n);
// relative field vector (slave - master)
rfv = Vector<Real>(it_field[slave]);
rfv -= Vector<Real>(it_field[master]);
// normal projection of relative field
const Vector<Real> normal_v = it_normal[n];
np_rfv = normal_v;
np_rfv *= rfv.dot(normal_v);
// subract normal projection from relative field to get the tangential
// projection
rfv -= np_rfv;
rel_tang_field.push_back(rfv);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::computeRelativeNormalField(
const Array<Real> & field, Array<Real> & rel_normal_field) const {
AKANTU_DEBUG_IN();
// resize arrays to zero
rel_normal_field.resize(0);
UInt dim = this->model.getSpatialDimension();
// Real * field_p = field.storage();
// Real * normals_p = this->normals.storage();
Array<Real>::const_iterator<Vector<Real>> it_field = field.begin(dim);
Array<Real>::const_iterator<Vector<Real>> it_normal =
this->normals.getArray().begin(dim);
Vector<Real> rfv(dim);
UInt nb_contact_nodes = this->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// nodes
UInt slave = this->slaves(n);
UInt master = this->masters(n);
// relative field vector (slave - master)
rfv = Vector<Real>(it_field[slave]);
rfv -= Vector<Real>(it_field[master]);
// length of normal projection of relative field
const Vector<Real> normal_v = it_normal[n];
rel_normal_field.push_back(rfv.dot(normal_v));
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Int NTNContact::getNodeIndex(UInt node) const {
AKANTU_DEBUG_IN();
Int slave_i = NTNBaseContact::getNodeIndex(node);
Int master_i = this->masters.find(node);
AKANTU_DEBUG_OUT();
return std::max(slave_i, master_i);
}
/* -------------------------------------------------------------------------- */
void NTNContact::printself(std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNContact [" << std::endl;
NTNBaseContact::printself(stream, indent);
stream << space << " + masters : " << std::endl;
this->masters.printself(stream, indent + 2);
stream << space << " + lumped_boundary_mastres : " << std::endl;
this->lumped_boundary_masters.printself(stream, indent + 2);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::syncArrays(SyncChoice sync_choice) {
AKANTU_DEBUG_IN();
NTNBaseContact::syncArrays(sync_choice);
this->masters.syncElements(sync_choice);
this->lumped_boundary_masters.syncElements(sync_choice);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id) {
AKANTU_DEBUG_IN();
/*
#ifdef AKANTU_USE_IOHELPER
const Array<UInt> & nodal_filter = this->slaves.getArray();
#define ADD_FIELD(field_id, field, type) \
internalAddDumpFieldToDumper(dumper_name, \
field_id, \
new DumperIOHelper::NodalField< type, true, \
Array<type>, \
Array<UInt> >(field, 0, 0, &nodal_filter))
*/
if (field_id == "lumped_boundary_master") {
internalAddDumpFieldToDumper(
dumper_name, field_id,
new dumper::NodalField<Real>(this->lumped_boundary_masters.getArray()));
} else {
NTNBaseContact::addDumpFieldToDumper(dumper_name, field_id);
}
/*
#undef ADD_FIELD
#endif
*/
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.hh
index c5754157f..ca9c16b90 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.hh
@@ -1,151 +1,166 @@
/**
* @file ntn_contact.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief contact for node to node discretization
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_CONTACT_HH__
#define __AST_NTN_CONTACT_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_contact.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class NTNContact : public NTNBaseContact {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNContact(SolidMechanicsModel & model, const ContactID & id = "contact",
const MemoryID & memory_id = 0);
virtual ~NTNContact(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// add surface pair and pair nodes according to the surface normal
void addSurfacePair(const Surface & slave, const Surface & master,
UInt surface_normal_dir);
/// fills the pairs vector with interface node pairs (*,0)=slaves,
/// (*,1)=masters
static void pairInterfaceNodes(const ElementGroup & slave_boundary,
const ElementGroup & master_boundary,
UInt surface_normal_dir, const Mesh & mesh,
Array<UInt> & pairs);
// add node pairs from a list with pairs(*,0)=slaves and pairs(*,1)=masters
void addNodePairs(const Array<UInt> & pairs);
/// add node pair
virtual void addSplitNode(UInt slave, UInt master);
/// update (compute the normals on the master nodes)
virtual void updateNormals();
/// update the lumped boundary B matrix
virtual void updateLumpedBoundary();
/// update the impedance matrix
virtual void updateImpedance();
/// impose the normal contact force
virtual void applyContactPressure();
/// dump restart file
virtual void dumpRestart(const std::string & file_name) const;
/// read restart file
virtual void readRestart(const std::string & file_name);
/// compute the normal gap
virtual void computeNormalGap(Array<Real> & gap) const {
this->computeRelativeNormalField(this->model.getCurrentPosition(), gap);
};
/// compute relative normal field (only value that has to be multiplied with
/// the normal)
/// relative to master nodes
virtual void computeRelativeNormalField(const Array<Real> & field,
Array<Real> & rel_normal_field) const;
/// compute relative tangential field (complet array)
/// relative to master nodes
virtual void
computeRelativeTangentialField(const Array<Real> & field,
Array<Real> & rel_tang_field) const;
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/// synchronize arrays
virtual void syncArrays(SyncChoice sync_choice);
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
// virtual void addDumpFieldVector(const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO(Masters, masters, const SynchronizedArray<UInt> &)
AKANTU_GET_MACRO(LumpedBoundaryMasters, lumped_boundary_masters,
const SynchronizedArray<Real> &)
/// get interface node pairs (*,0) are slaves, (*,1) are masters
void getNodePairs(Array<UInt> & pairs) const;
/// get index of node in either slaves or masters array
/// if node is in neither of them, return -1
Int getNodeIndex(UInt node) const;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// array of master nodes
SynchronizedArray<UInt> masters;
/// lumped boundary of master nodes
SynchronizedArray<Real> lumped_boundary_masters;
// element list for dump and lumped_boundary
ElementTypeMapArray<UInt> master_elements;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "ntn_contact_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const NTNContact & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_NTN_CONTACT_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction.hh
index 1707dd2b3..669c13c2c 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction.hh
@@ -1,85 +1,100 @@
/**
* @file ntn_friction.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of friction for node to node contact
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICTION_HH__
#define __AST_NTN_FRICTION_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_friction.hh"
#include "ntn_friclaw_coulomb.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <template <class> class FrictionLaw = NTNFricLawCoulomb,
class Regularisation = NTNFricRegNoRegularisation>
class NTNFriction : public FrictionLaw<Regularisation> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFriction(NTNBaseContact * contact, const FrictionID & id = "friction",
const MemoryID & memory_id = 0);
virtual ~NTNFriction(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// apply the friction force
virtual void applyFrictionTraction();
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
protected:
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
// virtual void addDumpFieldToDumper(const std::string & dumper_name,
// const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template <template <class> class FrictionLaw, class Regularisation>
inline std::ostream &
operator<<(std::ostream & stream,
const NTNFriction<FrictionLaw, Regularisation> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "ntn_friction_tmpl.hh"
#endif /* __AST_NTN_FRICTION_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction_tmpl.hh
index 4ec271a9b..cbda34967 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_friction_tmpl.hh
@@ -1,81 +1,96 @@
/**
* @file ntn_friction_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_contact.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <template <class> class FrictionLaw, class Regularisation>
NTNFriction<FrictionLaw, Regularisation>::NTNFriction(
NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id)
: FrictionLaw<Regularisation>(contact, id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <template <class> class FrictionLaw, class Regularisation>
void NTNFriction<FrictionLaw, Regularisation>::applyFrictionTraction() {
AKANTU_DEBUG_IN();
NTNContact * ntn_contact = dynamic_cast<NTNContact *>(this->contact);
SolidMechanicsModel & model = ntn_contact->getModel();
Array<Real> & residual = model.getResidual();
UInt dim = model.getSpatialDimension();
const SynchronizedArray<UInt> & masters = ntn_contact->getMasters();
const SynchronizedArray<UInt> & slaves = ntn_contact->getSlaves();
const SynchronizedArray<Real> & l_boundary_slaves =
ntn_contact->getLumpedBoundarySlaves();
const SynchronizedArray<Real> & l_boundary_masters =
ntn_contact->getLumpedBoundaryMasters();
UInt nb_contact_nodes = ntn_contact->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt master = masters(n);
UInt slave = slaves(n);
for (UInt d = 0; d < dim; ++d) {
residual(master, d) +=
l_boundary_masters(n) * this->friction_traction(n, d);
residual(slave, d) -=
l_boundary_slaves(n) * this->friction_traction(n, d);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <template <class> class FrictionLaw, class Regularisation>
void NTNFriction<FrictionLaw, Regularisation>::printself(std::ostream & stream,
int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTNFriction [" << std::endl;
FrictionLaw<Regularisation>::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.cc
index 3ebe6abf1..19e10d7a7 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.cc
@@ -1,395 +1,410 @@
/**
* @file ntn_initiation_function.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of initializing ntn and ntrf friction
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_initiation_function.hh"
#include "mIIasym_contact.hh"
#include "ntn_friction.hh"
#include "ntrf_friction.hh"
// friction regularisations
#include "ntn_fricreg_rubin_ampuero.hh"
#include "ntn_fricreg_simplified_prakash_clifton.hh"
// friction laws
#include "ntn_friclaw_linear_cohesive.hh"
#include "ntn_friclaw_linear_slip_weakening.hh"
#include "ntn_friclaw_linear_slip_weakening_no_healing.hh"
namespace akantu {
NTNBaseFriction * initializeNTNFriction(NTNBaseContact * contact,
ParameterReader & data) {
AKANTU_DEBUG_IN();
const std::string & friction_law = data.get<std::string>("friction_law");
const std::string & friction_reg =
data.get<std::string>("friction_regularisation");
NTNBaseFriction * friction;
bool is_ntn_contact = true;
if (dynamic_cast<NTRFContact *>(contact) != NULL ||
dynamic_cast<MIIASYMContact *>(contact) != NULL) {
is_ntn_contact = false;
}
if (friction_law == "coulomb") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction =
new NTNFriction<NTNFricLawCoulomb, NTNFricRegNoRegularisation>(
contact);
else
friction =
new NTRFFriction<NTNFricLawCoulomb, NTNFricRegNoRegularisation>(
contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction =
new NTNFriction<NTNFricLawCoulomb, NTNFricRegRubinAmpuero>(contact);
else
friction = new NTRFFriction<NTNFricLawCoulomb, NTNFricRegRubinAmpuero>(
contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawCoulomb,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawCoulomb,
NTNFricRegSimplifiedPrakashClifton>(contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
friction->setMixed<SynchronizedArray<Real>>("mu_s", data.get<Real>("mu_s"));
}
// Friction Law: Linear Slip Weakening
else if (friction_law == "linear_slip_weakening") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegNoRegularisation>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegNoRegularisation>(contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegRubinAmpuero>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegRubinAmpuero>(contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegSimplifiedPrakashClifton>(contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
friction->setMixed<SynchronizedArray<Real>>("mu_s", data.get<Real>("mu_s"));
friction->setMixed<SynchronizedArray<Real>>("mu_k", data.get<Real>("mu_k"));
friction->setMixed<SynchronizedArray<Real>>("d_c", data.get<Real>("d_c"));
}
// Friction Law: Linear Slip Weakening No Healing
else if (friction_law == "linear_slip_weakening_no_healing") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegNoRegularisation>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegNoRegularisation>(contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegRubinAmpuero>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegRubinAmpuero>(contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegSimplifiedPrakashClifton>(contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
friction->setMixed<SynchronizedArray<Real>>("mu_s", data.get<Real>("mu_s"));
friction->setMixed<SynchronizedArray<Real>>("mu_k", data.get<Real>("mu_k"));
friction->setMixed<SynchronizedArray<Real>>("d_c", data.get<Real>("d_c"));
}
// Friction Law: Linear Cohesive
else if (friction_law == "linear_cohesive") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearCohesive,
NTNFricRegNoRegularisation>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearCohesive,
NTNFricRegNoRegularisation>(contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction =
new NTNFriction<NTNFricLawLinearCohesive, NTNFricRegRubinAmpuero>(
contact);
else
friction =
new NTRFFriction<NTNFricLawLinearCohesive, NTNFricRegRubinAmpuero>(
contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearCohesive,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawLinearCohesive,
NTNFricRegSimplifiedPrakashClifton>(contact);
friction->setMixed<SynchronizedArray<Real>>("t_star",
data.get<Real>("t_star"));
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
friction->setMixed<SynchronizedArray<Real>>("G_c", data.get<Real>("G_c"));
friction->setMixed<SynchronizedArray<Real>>("tau_c",
data.get<Real>("tau_c"));
friction->setMixed<SynchronizedArray<Real>>("tau_r",
data.get<Real>("tau_r"));
}
else {
AKANTU_ERROR("Do not know the following friction law: " << friction_law);
}
AKANTU_DEBUG_OUT();
return friction;
}
/* -------------------------------------------------------------------------- */
NTNBaseFriction * initializeNTNFriction(NTNBaseContact * contact) {
AKANTU_DEBUG_IN();
std::pair<Parser::const_section_iterator, Parser::const_section_iterator>
sub_sect = getStaticParser().getSubSections(_st_friction);
Parser::const_section_iterator it = sub_sect.first;
const ParserSection & section = *it;
std::string friction_law = section.getName();
std::string friction_reg = section.getOption();
if (friction_reg == "") {
std::string friction_reg = "no_regularisation";
}
NTNBaseFriction * friction =
initializeNTNFriction(contact, friction_law, friction_reg);
friction->parseSection(section);
if (++it != sub_sect.second) {
AKANTU_DEBUG_WARNING("There were several friction sections in input file. "
<< "Only first one was used and all others ignored.");
}
AKANTU_DEBUG_OUT();
return friction;
}
/* -------------------------------------------------------------------------- */
NTNBaseFriction * initializeNTNFriction(NTNBaseContact * contact,
const std::string & friction_law,
const std::string & friction_reg) {
AKANTU_DEBUG_IN();
NTNBaseFriction * friction;
// check whether is is node-to-rigid-flat contact or mIIasym (which is also
// ntrf)
bool is_ntn_contact = true;
if (dynamic_cast<NTRFContact *>(contact) != NULL ||
dynamic_cast<MIIASYMContact *>(contact) != NULL) {
is_ntn_contact = false;
}
if (friction_law == "coulomb") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction =
new NTNFriction<NTNFricLawCoulomb, NTNFricRegNoRegularisation>(
contact);
else
friction =
new NTRFFriction<NTNFricLawCoulomb, NTNFricRegNoRegularisation>(
contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction =
new NTNFriction<NTNFricLawCoulomb, NTNFricRegRubinAmpuero>(contact);
else
friction = new NTRFFriction<NTNFricLawCoulomb, NTNFricRegRubinAmpuero>(
contact);
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawCoulomb,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawCoulomb,
NTNFricRegSimplifiedPrakashClifton>(contact);
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
}
// Friction Law: Linear Slip Weakening
else if (friction_law == "linear_slip_weakening") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegNoRegularisation>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegNoRegularisation>(contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegRubinAmpuero>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegRubinAmpuero>(contact);
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawLinearSlipWeakening,
NTNFricRegSimplifiedPrakashClifton>(contact);
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
}
// Friction Law: Linear Slip Weakening No Healing
else if (friction_law == "linear_slip_weakening_no_healing") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegNoRegularisation>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegNoRegularisation>(contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegRubinAmpuero>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegRubinAmpuero>(contact);
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawLinearSlipWeakeningNoHealing,
NTNFricRegSimplifiedPrakashClifton>(contact);
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
}
// Friction Law: Linear Cohesive
else if (friction_law == "linear_cohesive") {
if (friction_reg == "no_regularisation") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearCohesive,
NTNFricRegNoRegularisation>(contact);
else
friction = new NTRFFriction<NTNFricLawLinearCohesive,
NTNFricRegNoRegularisation>(contact);
} else if (friction_reg == "rubin_ampuero") {
if (is_ntn_contact)
friction =
new NTNFriction<NTNFricLawLinearCohesive, NTNFricRegRubinAmpuero>(
contact);
else
friction =
new NTRFFriction<NTNFricLawLinearCohesive, NTNFricRegRubinAmpuero>(
contact);
} else if (friction_reg == "simplified_prakash_clifton") {
if (is_ntn_contact)
friction = new NTNFriction<NTNFricLawLinearCohesive,
NTNFricRegSimplifiedPrakashClifton>(contact);
else
friction =
new NTRFFriction<NTNFricLawLinearCohesive,
NTNFricRegSimplifiedPrakashClifton>(contact);
} else {
AKANTU_ERROR("Do not know the following friction regularisation: "
<< friction_reg);
}
} else {
AKANTU_ERROR("Do not know the following friction law: " << friction_law);
}
AKANTU_DEBUG_OUT();
return friction;
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh
index ca6f28bd0..66cafa3cb 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh
@@ -1,33 +1,48 @@
/**
* @file ntn_initiation_function.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jan 04 2013
+ * @date last modification: Fri Feb 23 2018
*
* @brief initiation ntn and ntrf friction
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_friction.hh"
#include "ntrf_contact.hh"
#include "parameter_reader.hh"
namespace akantu {
NTNBaseFriction * initializeNTNFriction(NTNBaseContact * contact,
ParameterReader & data);
NTNBaseFriction * initializeNTNFriction(NTNBaseContact * contact);
NTNBaseFriction * initializeNTNFriction(NTNBaseContact * contact,
const std::string & friction_law,
const std::string & friction_reg);
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.cc
index eea242fc4..3737a4069 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.cc
@@ -1,306 +1,321 @@
/**
* @file ntrf_contact.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntrf_contact.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTRFContact::NTRFContact(SolidMechanicsModel & model, const ContactID & id,
const MemoryID & memory_id)
: NTNBaseContact(model, id, memory_id),
reference_point(model.getSpatialDimension()),
normal(model.getSpatialDimension()) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::setReferencePoint(Real x, Real y, Real z) {
AKANTU_DEBUG_IN();
Real coord[3];
coord[0] = x;
coord[1] = y;
coord[2] = z;
UInt dim = this->model.getSpatialDimension();
for (UInt d = 0; d < dim; ++d)
this->reference_point(d) = coord[d];
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::setNormal(Real x, Real y, Real z) {
AKANTU_DEBUG_IN();
UInt dim = this->model.getSpatialDimension();
Real coord[3];
coord[0] = x;
coord[1] = y;
coord[2] = z;
for (UInt d = 0; d < dim; ++d)
this->normal(d) = coord[d];
this->normal.normalize();
this->updateNormals();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::addSurface(const Surface & surf) {
AKANTU_DEBUG_IN();
const Mesh & mesh_ref = this->model.getFEEngine().getMesh();
try {
const ElementGroup & boundary = mesh_ref.getElementGroup(surf);
this->contact_surfaces.insert(&boundary);
// find slave nodes
for (ElementGroup::const_node_iterator nodes_it(boundary.node_begin());
nodes_it != boundary.node_end(); ++nodes_it) {
if (!this->model.isPBCSlaveNode(*nodes_it)) {
this->addSplitNode(*nodes_it);
}
}
} catch (debug::Exception e) {
AKANTU_DEBUG_INFO("NTRFContact addSurface did not found subboundary "
<< surf
<< " and ignored it. Other procs might have it :)");
}
// synchronize with depending nodes
findBoundaryElements(this->slaves.getArray(), this->slave_elements);
updateInternalData();
syncArrays(_added);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::addNodes(Array<UInt> & nodes) {
AKANTU_DEBUG_IN();
- UInt nb_nodes = nodes.getSize();
+ UInt nb_nodes = nodes.size();
UInt nb_compo = nodes.getNbComponent();
for (UInt n = 0; n < nb_nodes; ++n) {
for (UInt c = 0; c < nb_compo; ++c) {
this->addSplitNode(nodes(n, c));
}
}
// synchronize with depending nodes
findBoundaryElements(this->slaves.getArray(), this->slave_elements);
updateInternalData();
syncArrays(_added);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::updateNormals() {
AKANTU_DEBUG_IN();
// normal is the same for all slaves
this->normals.set(this->normal);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::updateImpedance() {
AKANTU_DEBUG_IN();
UInt nb_contact_nodes = getNbContactNodes();
Real delta_t = this->model.getTimeStep();
AKANTU_DEBUG_ASSERT(delta_t != NAN,
"Time step is NAN. Have you set it already?");
const Array<Real> & mass = this->model.getMass();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt slave = this->slaves(n);
Real imp = this->lumped_boundary_slaves(n) / mass(slave);
imp = 2 / delta_t / imp;
this->impedance(n) = imp;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::computeRelativeTangentialField(
const Array<Real> & field, Array<Real> & rel_tang_field) const {
AKANTU_DEBUG_IN();
// resize arrays to zero
rel_tang_field.resize(0);
UInt dim = this->model.getSpatialDimension();
Array<Real>::const_iterator<Vector<Real>> it_field = field.begin(dim);
Array<Real>::const_iterator<Vector<Real>> it_normal =
this->normals.getArray().begin(dim);
Vector<Real> rfv(dim);
Vector<Real> np_rfv(dim);
- UInt nb_contact_nodes = this->slaves.getSize();
+ UInt nb_contact_nodes = this->slaves.size();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// nodes
UInt node = this->slaves(n);
// relative field vector
rfv = it_field[node];
;
// normal projection of relative field
const Vector<Real> & normal_v = it_normal[n];
np_rfv = normal_v;
np_rfv *= rfv.dot(normal_v);
// subtract normal projection from relative field to get the tangential
// projection
rfv -= np_rfv;
rel_tang_field.push_back(rfv);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::computeNormalGap(Array<Real> & gap) const {
AKANTU_DEBUG_IN();
gap.resize(0);
UInt dim = this->model.getSpatialDimension();
Array<Real>::const_iterator<Vector<Real>> it_cur_pos =
this->model.getCurrentPosition().begin(dim);
Array<Real>::const_iterator<Vector<Real>> it_normal =
this->normals.getArray().begin(dim);
Vector<Real> gap_v(dim);
UInt nb_contact_nodes = this->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// nodes
UInt node = this->slaves(n);
// gap vector
gap_v = it_cur_pos[node];
gap_v -= this->reference_point;
// length of normal projection of gap vector
const Vector<Real> & normal_v = it_normal[n];
gap.push_back(gap_v.dot(normal_v));
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::computeRelativeNormalField(
const Array<Real> & field, Array<Real> & rel_normal_field) const {
AKANTU_DEBUG_IN();
// resize arrays to zero
rel_normal_field.resize(0);
UInt dim = this->model.getSpatialDimension();
Array<Real>::const_iterator<Vector<Real>> it_field = field.begin(dim);
Array<Real>::const_iterator<Vector<Real>> it_normal =
this->normals.getArray().begin(dim);
UInt nb_contact_nodes = this->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// nodes
UInt node = this->slaves(n);
const Vector<Real> & field_v = it_field[node];
const Vector<Real> & normal_v = it_normal[n];
rel_normal_field.push_back(field_v.dot(normal_v));
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::printself(std::ostream & stream, int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTRFContact [" << std::endl;
NTNBaseContact::printself(stream, indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTRFContact::addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id) {
AKANTU_DEBUG_IN();
/*
#ifdef AKANTU_USE_IOHELPER
const Array<UInt> & nodal_filter = this->slaves.getArray();
#define ADD_FIELD(field_id, field, type) \
internalAddDumpFieldToDumper(dumper_name, \
field_id, \
new DumperIOHelper::NodalField< type, true, \
Array<type>, \
Array<UInt> >(field, 0, 0, &nodal_filter))
*/
/*
if(field_id == "displacement") {
ADD_FIELD(field_id, this->model.getDisplacement(), Real);
}
else if(field_id == "contact_pressure") {
internalAddDumpFieldToDumper(dumper_name,
field_id,
new
DumperIOHelper::NodalField<Real>(this->contact_pressure.getArray()));
}
else {*/
NTNBaseContact::addDumpFieldToDumper(dumper_name, field_id);
//}
/*
#undef ADD_FIELD
#endif
*/
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.hh
index 28eef5a4b..ac3433e7c 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_contact.hh
@@ -1,111 +1,126 @@
/**
* @file ntrf_contact.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief contact for node to rigid flat interface
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTRF_CONTACT_HH__
#define __AST_NTRF_CONTACT_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_contact.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class NTRFContact : public NTNBaseContact {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTRFContact(SolidMechanicsModel & model, const ContactID & id = "contact",
const MemoryID & memory_id = 0);
virtual ~NTRFContact(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void setReferencePoint(Real x = 0., Real y = 0., Real z = 0.);
void setNormal(Real x = 1., Real y = 0., Real z = 0.);
/// add surface and nodes according to the surface normal
void addSurface(const Surface & surf);
// add nodes from a list
void addNodes(Array<UInt> & nodes);
/// update (copy the normal to all normals)
virtual void updateNormals();
/// update the impedance matrix
virtual void updateImpedance();
/// compute the normal gap
virtual void computeNormalGap(Array<Real> & gap) const;
/// compute relative normal field (only value that has to be multiplied with
/// the normal)
/// relative to master nodes
virtual void computeRelativeNormalField(const Array<Real> & field,
Array<Real> & rel_normal_field) const;
/// compute relative tangential field (complet array)
/// relative to master nodes
virtual void
computeRelativeTangentialField(const Array<Real> & field,
Array<Real> & rel_tang_field) const;
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
// virtual void addDumpFieldVector(const std::string & field_id);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// reference point for rigid flat surface
Vector<Real> reference_point;
/// outpointing normal of rigid flat surface
Vector<Real> normal;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "ntrf_contact_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const NTRFContact & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AST_NTRF_CONTACT_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction.hh
index 97bf1aeb7..4e5de52ec 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction.hh
@@ -1,77 +1,92 @@
/**
* @file ntrf_friction.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Fri Jun 18 2010
+ * @date last modification: Fri Feb 23 2018
*
* @brief friction for node to rigid flat interface
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTRF_FRICTION_HH__
#define __AST_NTRF_FRICTION_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_friclaw_coulomb.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <template <class> class FrictionLaw = NTNFricLawCoulomb,
class Regularisation = NTNFricRegNoRegularisation>
class NTRFFriction : public FrictionLaw<Regularisation> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTRFFriction(NTNBaseContact * contact, const FrictionID & id = "friction",
const MemoryID & memory_id = 0);
virtual ~NTRFFriction(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
/* ------------------------------------------------------------------------ */
/* Dumpable */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operato
template <template <class> class FrictionLaw, class Regularisation>
inline std::ostream &
operator<<(std::ostream & stream,
const NTRFFriction<FrictionLaw, Regularisation> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "ntrf_friction_tmpl.hh"
#endif /* __AST_NTRF_FRICTION_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction_tmpl.hh
index 2e0212824..5d5dc1bb1 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntrf_friction_tmpl.hh
@@ -1,90 +1,105 @@
/**
* @file ntrf_friction_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief implementation of node to rigid flat interface friction
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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 "ntrf_friction.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <template <class> class FrictionLaw, class Regularisation>
NTRFFriction<FrictionLaw, Regularisation>::NTRFFriction(
NTNBaseContact * contact, const FrictionID & id, const MemoryID & memory_id)
: FrictionLaw<Regularisation>(contact, id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <template <class> class FrictionLaw, class Regularisation>
void NTRFFriction<FrictionLaw, Regularisation>::printself(std::ostream & stream,
int indent) const {
AKANTU_DEBUG_IN();
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "NTRFFriction [" << std::endl;
FrictionLaw<Regularisation>::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/*
void NTRFFriction::addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
&(this->contact.getSlaves());
if(field_id == "is_sticking") {
this->internalAddDumpFieldToDumper(dumper_name,
field_id,
new
DumperIOHelper::NodalField<bool>(this->is_sticking.getArray()));
}
else if(field_id == "frictional_strength") {
this->internalAddDumpFieldToDumper(dumper_name,
field_id,
new
DumperIOHelper::NodalField<Real>(this->frictional_strength.getArray()));
}
else if(field_id == "friction_traction") {
this->internalAddDumpFieldToDumper(dumper_name,
field_id,
new
DumperIOHelper::NodalField<Real>(this->friction_traction.getArray()));
}
else if(field_id == "slip") {
this->internalAddDumpFieldToDumper(dumper_name,
field_id,
new DumperIOHelper::NodalField<Real>(this->slip.getArray()));
}
else {
this->contact.addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
*/
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/tasn_contact.hh b/extra_packages/traction-at-split-node-contact/src/tasn_contact.hh
index 31cabc401..f3b179e18 100644
--- a/extra_packages/traction-at-split-node-contact/src/tasn_contact.hh
+++ b/extra_packages/traction-at-split-node-contact/src/tasn_contact.hh
@@ -1,52 +1,68 @@
/**
- * @file akantu_simtools.hh
+ * @file tasn_contact.hh
*
+ * @author David Simon Kammer <david.kammer@epfl.ch>
*
+ * @date creation: Tue Dec 02 2014
+ * @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
- * Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Copyright (©) 2015-2018 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/>.
+ *
*/
// ast common
#include "manual_restart.hh"
#include "parameter_reader.hh"
#include "synchronized_array.hh"
// functions
#include "boundary_functions.hh"
#include "node_filter.hh"
// boundary conditions
#include "force_based_dirichlet.hh"
#include "inclined_flat_dirichlet.hh"
#include "spring_bc.hh"
// ntn/ntrf contact
#include "mIIasym_contact.hh"
#include "ntn_base_contact.hh"
#include "ntn_contact.hh"
#include "ntrf_contact.hh"
// ntn/ntrf friction
#include "ntn_base_friction.hh"
#include "ntn_friction.hh"
#include "ntrf_friction.hh"
// friction regularisations
#include "ntn_fricreg_no_regularisation.hh"
#include "ntn_fricreg_rubin_ampuero.hh"
#include "ntn_fricreg_simplified_prakash_clifton.hh"
// friction laws
#include "ntn_friclaw_coulomb.hh"
#include "ntn_friclaw_linear_cohesive.hh"
#include "ntn_friclaw_linear_slip_weakening.hh"
#include "ntn_friclaw_linear_slip_weakening_no_healing.hh"
// initiation of friction
#include "ntn_initiation_function.hh"

Event Timeline