Esempio n. 1
0
        static private void EvalComponent <T>(LevSetIntParams _inParams,
                                              int gamma, EquationComponentArgMapping <T> bf,
                                              MultidimensionalArray[][] argsPerComp, MultidimensionalArray[,] argsSum,
                                              int componentIdx,
                                              MultidimensionalArray ParamFieldValuesPos, MultidimensionalArray ParamFieldValuesNeg,
                                              int DELTA,
                                              Stopwatch timer,
                                              IDictionary <SpeciesId, MultidimensionalArray> LengthScales,
                                              CallComponent <T> ComponentFunc) where T : ILevelSetComponent
        {
            timer.Start();


            for (int i = 0; i < bf.m_AllComponentsOfMyType.Length; i++)    // loop over equation components
            {
                var comp = bf.m_AllComponentsOfMyType[i];

                LengthScales.TryGetValue(comp.NegativeSpecies, out _inParams.NegCellLengthScale);
                LengthScales.TryGetValue(comp.PositiveSpecies, out _inParams.PosCellLengthScale);

                argsPerComp[gamma][i].Clear();

                int NoOfArgs = bf.NoOfArguments[i];
                Debug.Assert(NoOfArgs == comp.ArgumentOrdering.Count);
                int NoOfParams = bf.NoOfParameters[i];
                Debug.Assert(NoOfParams == ((comp.ParameterOrdering != null) ? comp.ParameterOrdering.Count : 0));


                // map parameters
                _inParams.ParamsPos = new MultidimensionalArray[NoOfParams];
                _inParams.ParamsNeg = new MultidimensionalArray[NoOfParams];
                for (int c = 0; c < NoOfParams; c++)
                {
                    int targ = bf.AllToSub[i, c + NoOfArgs] - DELTA;
                    Debug.Assert(targ >= 0);
                    _inParams.ParamsPos[c] = ParamFieldValuesPos.ExtractSubArrayShallow(targ, -1, -1);
                    _inParams.ParamsNeg[c] = ParamFieldValuesNeg.ExtractSubArrayShallow(targ, -1, -1);
                }

                // evaluate equation components
                ComponentFunc(comp, gamma, i, _inParams);
#if DEBUG
                argsPerComp[gamma][i].CheckForNanOrInf();
#endif

                // sum up bilinear forms:
                {
                    MultidimensionalArray Summand = argsPerComp[gamma][i];

                    if (componentIdx >= 0)
                    {
                        for (int c = 0; c < NoOfArgs; c++)   // loop over arguments of equation component
                        {
                            int   targ   = bf.AllToSub[i, c];
                            int[] selSum = new int[Summand.Dimension];
                            selSum.SetAll(-1);
                            selSum[componentIdx] = c;

                            MultidimensionalArray Accu = argsSum[gamma, targ];

                            //int[] selAccu = new int[Accu.Dimension];
                            //selAccu.SetAll(-1);
                            //selAccu[componentIdx] = targ;
#if DEBUG
                            Summand.ExtractSubArrayShallow(selSum).CheckForNanOrInf();
#endif

                            Accu.Acc(1.0, Summand.ExtractSubArrayShallow(selSum));
                        }
                    }
                    else
                    {
                        // affin
#if DEBUG
                        Summand.CheckForNanOrInf();
#endif
                        MultidimensionalArray Accu = argsSum[gamma, 0];
                        Accu.Acc(1.0, Summand);
                    }
                }
            }
            timer.Stop();
        }
Esempio n. 2
0
 public ChunkPort()
 {
     call = new CallComponent(this);
     obj  = new ObjectComponent(this);
 }