24 const std::filesystem::path root(
argv[1]);
25 const auto folder = std::filesystem::temp_directory_path() /
26 (
"bicrystal-corner-1915-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()));
27 const auto input = folder /
"inputFiles";
28 std::filesystem::create_directories(input);
29 std::filesystem::create_directories(folder /
"F");
30 std::filesystem::copy_file(root /
"Library/Materials/W.txt", input /
"W.txt");
32 std::filesystem::copy_file(root /
"Library/Meshes/bicrystal_48.msh", input /
"mesh.msh");
33 std::filesystem::copy_file(root /
"Library/DislocationDynamics/DD.txt", input /
"DD.txt");
34 std::filesystem::create_directories(folder /
"config");
35 const double length=3671.9477120460206;
37 std::ofstream
f(input /
"DefectiveCrystal.txt");
38 f <<
"physics=DislocationDynamics;\nuseFEM=0;\nNsteps=0;\nmaxResolveSteps=0;\ndtMax=1;\noutputFrequency=1;\noutputBinary=0;\nstartAtTimeStep=0;\nperiodicImageSize=0 0 0;\nEwaldLengthFactor=0;\n";
39 std::ofstream
p(input /
"polycrystal.txt");
40 p << std::setprecision(17) <<
"materialFile=W.txt;\nmeshFile=mesh.msh;\nabsoluteTemperature=300;\nC2G1=1 0 0 0 1 0 0 0 1;\n"
41 <<
"C2G2=0.8 0 0.6 0 1 0 -0.6 0 0.8;\nF=" << length <<
" 0 0 0 " << length <<
" 0 0 0 " << length
42 <<
";\nX0=0 0 0;\nperiodicFaceIDs=-1;\n";
45 const auto grain=base.poly.grain(2);
46 const auto plane=base.dislocationDynamics().periodicGlidePlaneFactory.get(
model::GlidePlaneKey<3>(Eigen::Vector3d(902.05206058187161,-1503.4201009697861,1202.7360807758289),grain->reciprocalLatticeDirection(Eigen::Vector3d(0.42426406871192851,-0.70710678118654757,0.56568542494923801))));
47 std::vector<Eigen::Vector2d>
vertices;
48 std::ifstream source(root/
"tests/data/bicrystalCorner1915.txt");
49 require(
bool(source),
"Missing frame 1915 contour");
56 double referenceArea=0;
57 for(
size_t start=0;start<
vertices.size();++start)
59 for(
bool reverse : {
false,
true})
61 std::vector<std::pair<Eigen::Vector2d,const int* const>> polygon;
66 const auto result=plane->polygonPatchIntersection(polygon,
false);
67 require(
result.size()>=3,
"Corner clipping discarded the retained area");
71 const Eigen::Vector2d
a=std::get<0>(
result[
i]);
74 const auto patch=plane->getPatch(std::get<1>(
result[
i]));
77 for(
const auto& edge : patch->edges())
79 const Eigen::Vector2d d=*edge->sink-*edge->source;
80 const Eigen::Vector2d offset=
a-*edge->source;
81 require((d.x()*offset.y()-d.y()*offset.x())/d.norm()>-1.e-8,
82 "Clipping retained a node outside its patch");
88 require(std::abs(
area)>1.0,
"Corner clipping erased slipped area");
92 require(std::abs(
area+referenceArea)<1.e-6,
"Corner clipping depends on polygon orientation");
96 std::filesystem::remove_all(folder);
97 std::cout<<
"PASS: frame 1915 near-coincident seam vertices in both orientations and every cyclic ordering\n";
100 catch(
const std::exception& error)
102 std::cerr<<error.what()<<std::endl;