public IVector GetEquivalentNodalLoads(ISubdomain subdomain, IVectorView solution, double constraintScalingFactor) { //var times = new Dictionary<string, TimeSpan>(); //var totalStart = DateTime.Now; //times.Add("rowIndexCalculation", DateTime.Now - totalStart); //times.Add("element", TimeSpan.Zero); //times.Add("addition", TimeSpan.Zero); var subdomainEquivalentForces = Vector.CreateZero(subdomain.FreeDofOrdering.NumFreeDofs); foreach (IElement element in subdomain.Elements) //TODO: why go through all the elements? Most of them will not have Dirichlet bc. { //var elStart = DateTime.Now; IMatrix elementK = elementProvider.Matrix(element); //double[] localSolution = subdomain.CalculateElementNodalDisplacements(element, solution); //double[] localdSolution = subdomain.CalculateElementIcrementalConstraintDisplacements(element, constraintScalingFactor); double[] localdSolution = subdomain.CalculateElementIncrementalConstraintDisplacements(element, constraintScalingFactor); var elementEquivalentForces = elementK.Multiply(localdSolution); subdomain.FreeDofOrdering.AddVectorElementToSubdomain(element, elementEquivalentForces, subdomainEquivalentForces); //times["addition"] += DateTime.Now - elStart; } //var totalTime = DateTime.Now - totalStart; return(subdomainEquivalentForces); }