Ejemplo n.º 1
0
        public IterationInfo()
        {
            var msgMatchers = new MsgMatcher[] {
                new MsgMatcher(State.Step, State.Attempt, RE_STEP, (m) => Step = m.to_i()),
                new MsgMatcher(State.Attempt, State.Iteration, RE_ATTEMPT, (m) => {
                    Increment       = m.to_i(1);
                    Attempt         = m.to_i(2);
                    TimeIncrement   = m.to_f(3);
                    MomentConverged = false;
                    ForceConverged  = false;
                }),
                new MsgMatcher(State.Iteration, State.AverageForce, RE_ITERATION, (m) => Iteration               = m.to_i(1)),
                new MsgMatcher(State.AverageForce, State.ResidualForce, RE_AVERAGE_FORCE, (m) => AverageForce    = m.to_f()),
                new MsgMatcher(State.ResidualForce, State.DispIncrement, RE_RESIDUAL_FORCE, (m) => ResidualForce = m.to_f()),
                new MsgMatcher(State.DispIncrement, State.DispIncrement, RE_INSTANCE, null, State.DispCorrection),
                new MsgMatcher(State.DispCorrection, State.DispCorrection, RE_INSTANCE, null, State.ForceConverged),
                new MsgMatcher(State.ForceConverged, State.AverageMoment, RE_FORCE_CONVERGED, (m) => ForceConverged = true, State.AverageMoment, RE_INSTANCE),
                new MsgMatcher(State.AverageMoment, State.ResidualMoment, RE_AVERAGE_MOMENT, (m) => AverageMonent   = m.to_f()),
                new MsgMatcher(State.ResidualMoment, State.RotIncrement, RE_RESIDUAL_MOMENT, (m) => ResidualMoment  = m.to_f()),
                new MsgMatcher(State.RotIncrement, State.RotIncrement, RE_INSTANCE, null, State.RotCorrection),
                new MsgMatcher(State.RotCorrection, State.RotCorrection, RE_INSTANCE, null, State.MomentConverged),
                new MsgMatcher(State.MomentConverged, State.IterationEnded, RE_MOMENT_CONVERGED, (m) => MomentConverged = true, State.IterationEnded, RE_INSTANCE),
            };

            _pMap = new Dictionary <State, Func <string, State> >();
            foreach (var item in msgMatchers)
            {
                _pMap.Add(item.Current, item.Function());
            }

            // End of Iteration
            _pMap.Add(State.IterationEnded, s => {
                IterationEnded.Invoke(this);
                return((ForceConverged && MomentConverged) ? State.NextIncrement : State.Iteration);
            });

            _pMap.Add(State.NextIncrement,
                      s =>
            {
                var ans = RE_NEXT.Match(s);
                if (ans.Success)
                {
                    if (ans.Groups[1].Value == "1.00")
                    {
                        StepEnded.Invoke(this);
                        return(State.Step);
                    }
                    return(State.Attempt);
                }
                return(State.NextIncrement);
            });

            Reset();
        }
 protected void OnIterationEnded(ILayoutInfoIterationEventArgs <TVertex, TEdge, TVertexInfo, TEdgeInfo> e)
 {
     IterationEnded?.Invoke(this, e);
 }
Ejemplo n.º 3
0
 internal virtual void RaiseIterationEnded([NotNull] ILayoutIterationEventArgs <TVertex> args)
 {
     IterationEnded?.Invoke(this, args);
 }