Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
DDtimeStepper.cpp
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_DDtimeStepper_cpp_
9#define model_DDtimeStepper_cpp_
10
11#include <cfloat>
12#include <DDtimeStepper.h>
13
14#include <DislocationNetwork.h>
15
16namespace model
17{
18
19 template <int dim>
21 /* init */ DN(DN_in)
22 /* init */,timeSteppingMethod(TextFileParser(DN.ddBase.simulationParameters.traitsIO.inputFilesFolder+"/DD.txt").readString("timeSteppingMethod", true))
23 /* init */,dxMax(TextFileParser(DN.ddBase.simulationParameters.traitsIO.inputFilesFolder+"/DD.txt").readScalar<double>("dxMax", true))
24 {
25 if (dxMax < FLT_EPSILON)
26 {
27 throw std::runtime_error("dxMax must be > FLT_EPSILON.");
28 }
29 }
30
31 template <int dim>
32 double DDtimeStepper<dim>::getDt(const double& vRef, const double& vFactor) const
33 {
34 if(timeSteppingMethod=="fixed" || timeSteppingMethod=="Fixed" || timeSteppingMethod=="FIXED")
35 {
36 return DN.ddBase.simulationParameters.dtMax;
37 }
38 else if(timeSteppingMethod=="adaptive" || timeSteppingMethod=="Adaptive" || timeSteppingMethod=="ADAPTIVE")
39 {
40 double vmax = 0.0;
41 long int vmaxID=-1;
42 for (const auto &nodeIter : DN.networkNodes())
43 {
44 if( !nodeIter.second.lock()->isBoundaryNode()
45 && nodeIter.second.lock()->glidePlanes().size()==1)
46 {
47 const double vNorm(nodeIter.second.lock()->get_V().norm());
48 if (vNorm > vmax)
49 {
50 vmax = vNorm;
51 vmaxID=nodeIter.second.lock()->sID;
52 }
53 }
54 }
55// const double vRef(1.0);
56 const float vEff(vmax+vRef*std::exp(-vmax/(vRef*vFactor))); // use float to truncate some floating point digits
57 std::cout<<" (vMax="<<vmax<<", vMaxID="<<vmaxID<<", vRef="<<vRef<<", vEff="<<vEff<<")"<<std::flush;
58 return std::min(dxMax / vEff,DN.ddBase.simulationParameters.dtMax);
59 }
60 else
61 {
62 throw std::runtime_error("Unkonwn timeSteppingMethod "+timeSteppingMethod);
63 return 0.0;
64 }
65 }
66
67template struct DDtimeStepper<3>;
68
69} // end namespace
70#endif
71
DDtimeStepper(const DislocationNetwork< dim > &DN_in)
const std::string timeSteppingMethod
double getDt(const double &vRef, const double &vFactor) const
const DislocationNetwork< dim > & DN