OrderUnconstrainedDofs(Model2D_old model)
        {
            ITable <XNode, StructuralDof, double> constraints = model.Constraints;
            var standardDofs = new DofTable <StructuralDof>();
            var enrichedDofs = new DofTable <EnrichedDof>();
            int dofCounter   = 0;

            foreach (XNode node in model.Nodes)
            {
                // Standard free dofs. No rotational dofs. They can be X or Y. One or both of them may be constrained.
                if (!constraints.Contains(node, StructuralDof.TranslationX))
                {
                    standardDofs[node, StructuralDof.TranslationX] = dofCounter++;
                }
                if (!constraints.Contains(node, StructuralDof.TranslationY))
                {
                    standardDofs[node, StructuralDof.TranslationY] = dofCounter++;
                }

                // Enriched dofs. No rotational dofs. They cannot be constrained.
                foreach (IEnrichmentItem2D enrichment in node.EnrichmentItems.Keys)
                {
                    foreach (EnrichedDof dofType in enrichment.Dofs)
                    {
                        enrichedDofs[node, dofType] = dofCounter++;
                    }
                }
            }
            return(standardDofs, enrichedDofs);
            //TODO: Also return each table's count, by keeping separate counters. This avoids the O(numRows) Table.Count()
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="solution"></param>
        /// <returns>A nodesCount x 2 array, where each row stores the x and y displacements of that node</returns>
        public double[,] GatherNodalDisplacements(Model2D_old model, Vector solution)
        {
            double[,] result = new double[model.Nodes.Count, 2];
            for (int i = 0; i < model.Nodes.Count; ++i)
            {
                XNode node = model.Nodes[i];

                bool isXStandard = standardDofs.TryGetValue(node, StructuralDof.TranslationX, out int globalStandardDofX);
                if (isXStandard)
                {
                    result[i, 0] = solution[globalStandardDofX];
                }
                else
                {
                    result[i, 0] = model.Constraints[node, StructuralDof.TranslationX];
                }

                bool isYStandard = standardDofs.TryGetValue(node, StructuralDof.TranslationY, out int globalStandardDofY);
                if (isYStandard)
                {
                    result[i, 1] = solution[globalStandardDofY];
                }
                else
                {
                    result[i, 1] = model.Constraints[node, StructuralDof.TranslationY];
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Only standard free and standard constrained dofs.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="cluster"></param>
        /// <returns></returns>
        public static XClusterDofOrderer CreateNodeMajor(Model2D_old model, XCluster2D cluster)
        {
            (int numConstrainedDofs, DofTable <StructuralDof> constrainedDofs) = OrderConstrainedDofs(model.Constraints);
            (int numStandardDofs, DofTable <StructuralDof> standardDofs)       = OrderStandardDofs(model);

            return(new XClusterDofOrderer(cluster, numConstrainedDofs, constrainedDofs, numStandardDofs, standardDofs));
        }
Exemplo n.º 4
0
 public IntersectedMeshOutputAveraging(Model2D_old model, ICrackDescription crackGeometry, string pathNoExtension)
 {
     this.crackGeometry   = crackGeometry;
     this.model           = model;
     this.pathNoExtension = pathNoExtension;
     this.triangulator    = new Triangulator2D <CartesianPoint>((x, y) => new CartesianPoint(x, y));
 }
        public static SeparateDofOrderer Create(Model2D_old model)
        {
            // TODO: I should probably have a Constraint or Constraints class, to decouple this class from the collections
            // used to represent constraints
            IDictionary <XNode, HashSet <StructuralDof> > nodalDofTypes = FindUniqueDofTypes(model.Elements);

            (int standardDofsCount, DofTable <StructuralDof> standardDofs) =
                OrderStandardDofs(nodalDofTypes, model.Constraints);
            (int constrainedDofsCount, DofTable <StructuralDof> constrainedDofs) =
                OrderConstrainedDofs(model.Constraints);
            (int enrichedDofsCount, DofTable <EnrichedDof> enrichedDofs) =
                OrderEnrichedDofs(model.Nodes, standardDofsCount);

            #region DEBUG code
            //Console.WriteLine("------------------------ DEBUG ------------------------------");
            //Console.WriteLine("Free standard dofs: ");
            //Console.WriteLine(standardDofs);
            //Console.WriteLine("Enriched dofs: ");
            //Console.WriteLine(enrichedDofs);
            //Console.WriteLine("Constrained dofs: ");
            //Console.WriteLine(constrainedDofs);
            //Console.WriteLine("------------------------ /DEBUG ------------------------------");
            #endregion

            return(new SeparateDofOrderer(constrainedDofsCount, constrainedDofs, enrichedDofsCount, enrichedDofs,
                                          standardDofsCount, standardDofs));
        }
Exemplo n.º 6
0
        public ITable <XNode, EnrichedDof, double> GatherEnrichedNodalDisplacements(Model2D_old model, Vector solution)
        {
            var table = new Table <XNode, EnrichedDof, double>();

            foreach (var row in enrichedDofs)
            {
                table[row.row, row.col] = solution[row.val];
            }
            return(table);
        }
        public static InterleavedDofOrderer Create(Model2D_old model)
        {
            // TODO: I should probably have a Constraint or Constraints class, to decouple this class from the collections
            // used to represent constraints
            (DofTable <StructuralDof> standardDofs, DofTable <EnrichedDof> enrichedDofs) =
                OrderUnconstrainedDofs(model);
            (int constrainedDofsCount, DofTable <StructuralDof> constrainedDofs) =
                OrderConstrainedDofs(model.Constraints);

            #region DEBUG code
            //Console.WriteLine("------------------------ DEBUG ------------------------------");
            //Console.WriteLine("Free standard dofs: ");
            //Console.WriteLine(standardDofs);
            //Console.WriteLine("Enriched dofs: ");
            //Console.WriteLine(enrichedDofs);
            //Console.WriteLine("Constrained dofs: ");
            //Console.WriteLine(constrainedDofs);
            //Console.WriteLine("------------------------ /DEBUG ------------------------------");
            #endregion

            return(new InterleavedDofOrderer(constrainedDofsCount, constrainedDofs, enrichedDofs.EntryCount, enrichedDofs,
                                             standardDofs.EntryCount, standardDofs));
        }
Exemplo n.º 8
0
        private static (int numStandardDofs, DofTable <StructuralDof> standardDofs) OrderStandardDofs(Model2D_old model)
        {
            ITable <XNode, StructuralDof, double> constraints = model.Constraints;
            var standardDofs = new DofTable <StructuralDof>();
            int counter      = 0;

            foreach (var node in model.Nodes)
            {
                if (!constraints.Contains(node, StructuralDof.TranslationX))
                {
                    standardDofs[node, StructuralDof.TranslationX] = counter++;
                }
                if (!constraints.Contains(node, StructuralDof.TranslationY))
                {
                    standardDofs[node, StructuralDof.TranslationY] = counter++;
                }
            }
            return(counter, standardDofs);
        }
Exemplo n.º 9
0
 public ITable <XNode, EnrichedDof, double> GatherEnrichedNodalDisplacements(Model2D_old model, Vector solution)
 {
     throw new InvalidOperationException("This method does not make sense for this dofOrderer. Refactor them.");
 }
Exemplo n.º 10
0
 public StressRecovery(Model2D_old model, IDofOrderer dofOrderer)
 {
     this.model      = model;
     this.dofOrderer = dofOrderer;
 }
Exemplo n.º 11
0
 public DisplacementOutput(Model2D_old model, IDofOrderer dofOrderer)
 {
     this.model      = model;
     this.dofOrderer = dofOrderer;
 }
Exemplo n.º 12
0
 public TensorOutput(Model2D_old model, IDofOrderer dofOrderer)
 {
     this.model      = model;
     this.dofOrderer = dofOrderer;
 }