コード例 #1
0
ファイル: Temperature.cs プロジェクト: SpiceSharp/SpiceSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="Temperature" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Temperature(ParallelBindingContext context)
            : base(context)
        {
            var parameters = context.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(ITemperatureBehavior), out var dist))
            {
                _workload = new Workload(dist, parameters.Entities.Count);
            }
        }
コード例 #2
0
ファイル: Time.cs プロジェクト: saugkim/aaa_SpiceSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="Time" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Time(ParallelBindingContext context)
            : base(context)
        {
            var parameters = context.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(ITimeBehavior), out var dist) && dist != null)
            {
                _initWorkload = new Workload(dist, parameters.Entities.Count);
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BiasingUpdate"/> class.
        /// </summary>
        /// <param name="name">The name of the behavior.</param>
        /// <param name="simulation">The parallel simulation.</param>
        public BiasingUpdate(string name, ParallelSimulation simulation)
            : base(name)
        {
            var parameters = simulation.LocalParameters.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(IBiasingUpdateBehavior), out var dist) && dist != null)
            {
                _updateWorkload = new Workload(dist, parameters.Entities.Count);
            }
        }
コード例 #4
0
ファイル: Accept.cs プロジェクト: SpiceSharp/SpiceSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="Accept" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Accept(ParallelBindingContext context)
            : base(context)
        {
            var parameters = context.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(IAcceptBehavior), out var dist))
            {
                _probeWorkload  = new Workload(dist, parameters.Entities.Count);
                _acceptWorkload = new Workload(dist, parameters.Entities.Count);
            }
        }
コード例 #5
0
ファイル: Noise.cs プロジェクト: SpiceSharp/SpiceSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="Noise" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Noise(ParallelBindingContext context)
            : base(context)
        {
            var parameters = context.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(INoiseBehavior), out var dist) && dist != null)
            {
                _noiseInitializeWorkload = new Workload(dist, parameters.Entities.Count);
                _noiseComputeWorkload    = new Workload(dist, parameters.Entities.Count);
                if (context.TryGetState(out INoiseSimulationState parent))
                {
                    context.AddLocalState <INoiseSimulationState>(new NoiseSimulationState(parent));
                }
            }
        }
コード例 #6
0
ファイル: Frequency.cs プロジェクト: saugkim/aaa_SpiceSharp
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(ParallelBindingContext context)
            : base(context)
        {
            var parameters = context.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(IFrequencyBehavior), out var dist) && dist != null)
            {
                _initWorkload = new Workload(dist, parameters.Entities.Count);
                _loadWorkload = new Workload(dist, parameters.Entities.Count);
                if (context.TryGetState(out IComplexSimulationState parent))
                {
                    context.AddLocalState <IComplexSimulationState>(_state = new ComplexSimulationState(parent));
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Convergence" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Convergence(ParallelBindingContext context)
            : base(context)
        {
            var parameters = context.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(IConvergenceBehavior), out var dist) && dist != null)
            {
                _convergenceWorkload = new Workload <bool>((IWorkDistributor <bool>)dist, parameters.Entities.Count);
                if (context.TryGetState <IIterationSimulationState>(out var parent))
                {
                    if (!(parent is IterationSimulationState))
                    {
                        context.AddLocalState <IIterationSimulationState>(new IterationSimulationState(parent));
                    }
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(ParallelBindingContext context)
            : base(context)
        {
            var parameters = context.GetParameterSet <Parameters>();

            if (parameters.WorkDistributors.TryGetValue(typeof(IBiasingBehavior), out var dist) && dist != null)
            {
                _loadWorkload = new Workload(dist, parameters.Entities.Count);
                if (context.TryGetState(out IBiasingSimulationState bparent))
                {
                    context.AddLocalState <IBiasingSimulationState>(_state = new BiasingSimulationState(bparent));
                }
                if (context.TryGetState(out IIterationSimulationState cparent))
                {
                    context.AddLocalState <IIterationSimulationState>(new IterationSimulationState(cparent));
                }
            }
        }