Skip to content
Snippets Groups Projects
Commit 85169267 authored by podlesny's avatar podlesny
Browse files

make weakening patches settable from cfg file

parent 60b28899
Branches 2016-PippingKornhuberRosenauOncken
No related tags found
No related merge requests found
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
#include "config.h" #include "config.h"
#endif #endif
#include <vector>
#include <regex>
#include <dune/fufem/geometry/convexpolyhedron.hh> #include <dune/fufem/geometry/convexpolyhedron.hh>
#include <dune/contact/projections/normalprojection.hh> #include <dune/contact/projections/normalprojection.hh>
...@@ -14,6 +17,34 @@ ...@@ -14,6 +17,34 @@
#include "strikeslipfactory.hh" #include "strikeslipfactory.hh"
template <class HostGridType, class VectorTEMPLATE>
std::vector<double> StrikeSlipFactory<HostGridType, VectorTEMPLATE>::parsePatchString(const std::string& patch_str) {
std::vector<double> res;
std::string str = patch_str;
std::regex my_regex("[0-9]+\\.[0-9]+");
double lower = 0.0;
std::smatch match;
while (std::regex_search(str, match, my_regex)) {
double newVal = atof(match[0].str().c_str());
if (newVal <= lower) {
DUNE_THROW(Dune::Exception, "Invalid patches object in .cfg file: Interval boundaries are expected in ascending order.");
}
lower = newVal;
res.push_back(newVal);
str = match.suffix();
}
if (res.size() % 2 != 0) {
DUNE_THROW(Dune::Exception, "Invalid patches object in .cfg file: An even number of doubles representing a sequence of intervals is expected.");
}
return res;
}
template <class HostGridType, class VectorTEMPLATE> template <class HostGridType, class VectorTEMPLATE>
void StrikeSlipFactory<HostGridType, VectorTEMPLATE>::setBodies() { void StrikeSlipFactory<HostGridType, VectorTEMPLATE>::setBodies() {
// set up cuboid geometries // set up cuboid geometries
...@@ -35,10 +66,24 @@ void StrikeSlipFactory<HostGridType, VectorTEMPLATE>::setBodies() { ...@@ -35,10 +66,24 @@ void StrikeSlipFactory<HostGridType, VectorTEMPLATE>::setBodies() {
//triangleGeometries_[1]->addWeakeningPatch(frictionParset, origins[1], {origins[1][0] + lengths[1], origins[1][1], 0}); //triangleGeometries_[1]->addWeakeningPatch(frictionParset, origins[1], {origins[1][0] + lengths[1], origins[1][1], 0});
#elif MY_DIM == 2 #elif MY_DIM == 2
triangleGeometries_[0] = std::make_shared<TriangleGeometry>(origin, lengths[0], heights[0]); triangleGeometries_[0] = std::make_shared<TriangleGeometry>(origin, lengths[0], heights[0]);
triangleGeometries_[0]->addWeakeningPatch(frictionParset, triangleGeometries_[0]->A(), triangleGeometries_[0]->C());
triangleGeometries_[1] = std::make_shared<TriangleGeometry>(triangleGeometries_[0]->C(), -lengths[1], -heights[1]); triangleGeometries_[1] = std::make_shared<TriangleGeometry>(triangleGeometries_[0]->C(), -lengths[1], -heights[1]);
triangleGeometries_[1]->addWeakeningPatch(frictionParset, triangleGeometries_[1]->A(), triangleGeometries_[1]->C());
// parse weakening patches
using Patches = std::vector<std::array<double, 2> >;
std::string patches_str = this->parset_.template get<std::string>("boundary.friction.weakening.patches");
auto patches = parsePatchString(patches_str);
for (size_t i=0; i<patches.size(); i++) {
auto start1 = triangleGeometries_[1]->C() + patches[i]*(triangleGeometries_[1]->A() - triangleGeometries_[1]->C());
auto end1 = triangleGeometries_[1]->C() + patches[i+1]*(triangleGeometries_[1]->A() - triangleGeometries_[1]->C());
triangleGeometries_[1]->addWeakeningPatch(frictionParset, start1, end1);
auto start0 = triangleGeometries_[0]->A() + patches[i]*(triangleGeometries_[0]->C() - triangleGeometries_[0]->A());
auto end0 = triangleGeometries_[0]->A() + patches[i+1]*(triangleGeometries_[0]->C() - triangleGeometries_[0]->A());
triangleGeometries_[0]->addWeakeningPatch(frictionParset, start0, end0);
i++;
}
#else #else
#error CuboidGeometry only supports 2D and 3D!" #error CuboidGeometry only supports 2D and 3D!"
#endif #endif
......
...@@ -81,6 +81,8 @@ template <class HostGridType, class VectorType> class StrikeSlipFactory : public ...@@ -81,6 +81,8 @@ template <class HostGridType, class VectorType> class StrikeSlipFactory : public
return {0, 0, 1}; return {0, 0, 1};
#endif #endif
} }
std::vector<double> parsePatchString(const std::string& patch_str);
}; };
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment