示例#1
0
        private void InitializeDOFsWhenNoRotations()
        {
            if (rotNodes[0] == null && rotNodes[1] == null)
            {
                return;
            }

            IDofType[] translationalDOFTypes = new IDofType[3] {
                StructuralDof.TranslationX, StructuralDof.TranslationY, StructuralDof.TranslationZ
            };
            dofsWhenNoRotations = new IDofType[][] { translationalDOFTypes, translationalDOFTypes,
                                                     translationalDOFTypes, translationalDOFTypes, translationalDOFTypes, translationalDOFTypes,
                                                     translationalDOFTypes, translationalDOFTypes, translationalDOFTypes, translationalDOFTypes };
            noOfDOFs = 30;

            if (rotNodes[0] == null)
            {
                dofsWhenNoRotations = new IDofType[][] { nodalDOFTypes, translationalDOFTypes, translationalDOFTypes,
                                                         translationalDOFTypes, translationalDOFTypes, translationalDOFTypes };
                noOfDOFs = 21;
            }

            if (rotNodes[1] == null)
            {
                dofsWhenNoRotations = new IDofType[][] { translationalDOFTypes, nodalDOFTypes, translationalDOFTypes,
                                                         translationalDOFTypes, translationalDOFTypes, translationalDOFTypes };
                noOfDOFs = 21;
            }
        }
 internal LagrangeMultiplier(INode node, IDofType dof, ISubdomain subdomainPlus, ISubdomain subdomainMinus)
 {
     this.Node           = node;
     this.DofType        = dof;
     this.SubdomainPlus  = subdomainPlus;
     this.SubdomainMinus = subdomainMinus;
 }
示例#3
0
 public NEUOutputVectorProperties(int id, string title, string componentVector, IDofType dofType)
 {
     this.id              = id;
     this.title           = title;
     this.componentVector = componentVector;
     this.dofType         = dofType;
 }
示例#4
0
        public (int[] elementDofIndices, int[] subdomainDofIndices) MapFreeDofsElementToSubdomain(IElement element)
        {
            var collocationElement = ((ICollocationElement)element);

            //IList<INode> elementNodes = element.ElementType.DofEnumerator.GetNodesForMatrixAssembly(element);
            //IList<IList<DOFType>> elementDofs = element.ElementType.DofEnumerator.GetDOFTypes(element);

            // Count the dof superset (free and constrained) to allocate enough memory and avoid resizing
            var rowDofs             = collocationElement.GetDOFTypesForDOFEnumeration(element);
            int allElementDofs      = rowDofs.Count;
            var elementDofIndices   = new List <int>(allElementDofs);
            var subdomainDofIndices = new List <int>(allElementDofs);
            var elementDofs         = new IDofType[1][];

            elementDofs[0] = rowDofs.ToArray();

            int elementDofIdx = 0;

            for (int dofIdx = 0; dofIdx < elementDofs[0].Length; ++dofIdx)
            {
                bool isFree = FreeDofs.TryGetValue(collocationElement.CollocationPoint, elementDofs[0][dofIdx],
                                                   out int subdomainDofIdx);
                if (isFree)
                {
                    elementDofIndices.Add(elementDofIdx);
                    subdomainDofIndices.Add(subdomainDofIdx);
                }
                ++elementDofIdx;
            }

            return(elementDofIndices.ToArray(), subdomainDofIndices.ToArray());
        }
 /// <summary>
 /// Applies the provided load to all provided nodes.
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="freedomDegree">The axis of the nodal load.</param>
 /// <param name="signedMagnitudeIndividual">The magnitude of the nodal load with its sign.</param>
 public void ApplyNodalLoads(IEnumerable <Node> nodes, IDofType freedomDegree, double signedMagnitudeIndividual)
 {
     foreach (Node node in nodes)
     {
         ApplyNodalLoad(node, freedomDegree, signedMagnitudeIndividual);
     }
 }
示例#6
0
        public ContinuumElement3DNonLinear(IReadOnlyList <Node> nodes, IIsoparametricInterpolation3D interpolation,
                                           IQuadrature3D quadratureForStiffness, IQuadrature3D quadratureForMass,
                                           IGaussPointExtrapolation3D gaussPointExtrapolation,
                                           IContinuumMaterial3D material, IDynamicMaterial dynamicProperties)
        {
            this.dynamicProperties           = dynamicProperties;
            this.Interpolation               = interpolation;
            this.QuadratureForConsistentMass = quadratureForMass;
            this.nGaussPoints           = quadratureForStiffness.IntegrationPoints.Count;
            this.QuadratureForStiffness = quadratureForStiffness;
            this.Nodes = nodes;

            materialsAtGaussPoints = new IContinuumMaterial3D[nGaussPoints];
            for (int i = 0; i < nGaussPoints; i++)
            {
                materialsAtGaussPoints[i] = (IContinuumMaterial3D)material.Clone();
            }

            dofTypes = new IDofType[nodes.Count][];
            for (int i = 0; i < nodes.Count; i++)
            {
                dofTypes[i] = new IDofType[]
                {
                    StructuralDof.TranslationX, StructuralDof.TranslationY, StructuralDof.TranslationZ
                };
            }
        }
 /// <summary>
 /// Applies a load at the provided node.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="freedomDegree">The axis of the nodal load.</param>
 /// <param name="signedMagnitude">The magnitude of the nodal load with its sign.</param>
 public void ApplyNodalLoad(Node node, IDofType freedomDegree, double signedMagnitude)
 {
     model.Loads.Add(new Load()
     {
         Amount = signedMagnitude, Node = node, DOF = freedomDegree
     });
 }
 /// <summary>
 /// Enforces a displacement for all provided nodes.
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="freedomDegree">The axis of the prescribed displacement.</param>
 /// <param name="signedMagnitude">The magnitude of the prescribed displacement with its sign.</param>
 public void ApplyPrescribedDisplacements(IEnumerable <Node> nodes, IDofType freedomDegree, double signedMagnitude)
 {
     foreach (Node node in nodes)
     {
         ApplyPrescribedDisplacement(node, freedomDegree, signedMagnitude);
     }
 }
示例#9
0
        public ContinuumElement3D(IReadOnlyList <Node> nodes, IIsoparametricInterpolation3D interpolation,
                                  IQuadrature3D quadratureForStiffness, IQuadrature3D quadratureForMass,
                                  IGaussPointExtrapolation3D gaussPointExtrapolation,
                                  IReadOnlyList <IContinuumMaterial3D> materialsAtGaussPoints, IDynamicMaterial dynamicProperties)
        {
            this.dynamicProperties       = dynamicProperties;
            this.materialsAtGaussPoints  = materialsAtGaussPoints;
            this.GaussPointExtrapolation = gaussPointExtrapolation;
            this.Nodes         = nodes;
            this.Interpolation = interpolation;
            this.QuadratureForConsistentMass = quadratureForMass;
            //this.nGaussPoints = quadratureForStiffness.IntegrationPoints.Count;
            this.QuadratureForStiffness = quadratureForStiffness;

            //materialsAtGaussPoints = new IContinuumMaterial3D[nGaussPoints];
            //for (int i = 0; i < nGaussPoints; i++)
            //	materialsAtGaussPoints[i] = (IContinuumMaterial3D)material.Clone();

            dofTypes = new IDofType[nodes.Count][];
            for (int i = 0; i < nodes.Count; i++)
            {
                dofTypes[i] = new IDofType[]
                {
                    StructuralDof.TranslationX, StructuralDof.TranslationY, StructuralDof.TranslationZ
                };
            }

            strainsVec = new double[materialsAtGaussPoints.Count][];
            strainsVecLastConverged = new double[materialsAtGaussPoints.Count][];
            for (int gpoint = 0; gpoint < materialsAtGaussPoints.Count; gpoint++)
            {
                strainsVec[gpoint] = new double[6];
                strainsVecLastConverged[gpoint] = new double[6];
            }
        }
            public void WatchDof(INode node, IDofType dofType)
            {
                bool isAdded = watchedDofs.TryAdd(node, dofType, numWatchedDofs++);

                if (!isAdded)
                {
                    throw new ArgumentException(
                              $"At node {node.ID}, {dofType} is set to be watched more than once");
                }
            }
        /// <summary>
        /// Divides the provided load by the number of provided nodes and then applies it to all of them.
        /// </summary>
        /// <param name="nodes"></param>
        /// <param name="freedomDegree">The axis of the nodal load.</param>
        /// <param name="signedMagnitudeTotal">The magnitude of the nodal load with its sign.</param>
        public void DistributeNodalLoadEvenly(IEnumerable <Node> nodes, IDofType freedomDegree, double signedMagnitudeTotal)
        {
            int    numNodes       = nodes.Count();
            double individualLoad = signedMagnitudeTotal / numNodes;

            foreach (Node node in nodes)
            {
                ApplyNodalLoad(node, freedomDegree, individualLoad);
            }
        }
        public static void EmbeddedEBEinMatrix_NewtonRaphson()
        {
            // Model creation
            var model = new Model();

            // Subdomains
            //model.SubdomainsDictionary.Add(subdomainID, new Subdomain() { ID = 1 });
            model.SubdomainsDictionary.Add(subdomainID, new Subdomain(subdomainID));

            // Variables
            int      monitorNode = 41;
            IDofType monitorDof  = StructuralDof.TranslationZ;

            // Choose model
            EmbeddedEBEModelBuilder.EmbeddedExampleBuilder(model);

            //-----------------------------------------------------------------------------------------------------------
            // Model

            // Choose linear equation system solver
            //var solverBuilder = new SkylineSolver.Builder();
            //SkylineSolver solver = solverBuilder.BuildSolver(model);
            var solverBuilder        = new SuiteSparseSolver.Builder();
            SuiteSparseSolver solver = solverBuilder.BuildSolver(model);

            // Choose the provider of the problem -> here a structural problem
            var provider = new ProblemStructural(model, solver);

            // Choose child analyzer -> Child: NewtonRaphsonNonLinearAnalyzer
            int increments           = 100;
            var childAnalyzerBuilder = new LoadControlAnalyzer.Builder(model, solver, provider, increments)
            {
                ResidualTolerance = 1E-03, MaxIterationsPerIncrement = 10
            };
            LoadControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            // Choose parent analyzer -> Parent: Static
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Request output
            string outputFile = outputDirectory + "\\CNT-Embedded-3D_Results.txt";
            var    logger     = new TotalLoadsDisplacementsPerIncrementLog(model.SubdomainsDictionary[subdomainID], increments,
                                                                           model.NodesDictionary[monitorNode], monitorDof, outputFile);

            childAnalyzer.IncrementalLogs.Add(subdomainID, logger);

            // Run the analysis
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();

            // Create Paraview File
            var paraview = new ParaviewEmbedded3D(model, solver.LinearSystems[0].Solution, "test");

            paraview.CreateParaviewFile();
        }
示例#13
0
        public Dictionary <int, double> CalcBoundaryDofCoefficients(INode node, IDofType dofType)
        {
            var    coeffs = new Dictionary <int, double>();
            double inverseMultiplicity = 1.0 / node.SubdomainsDictionary.Count;

            foreach (int subdomainID in node.SubdomainsDictionary.Keys)
            {
                coeffs[subdomainID] = inverseMultiplicity;
            }
            return(coeffs);
        }
示例#14
0
        /// <summary>
        /// Returns -1 if the element does not engage the requested <see cref="IDofType"/>
        /// </summary>
        private int FindLocalDofIndex(Element element, Node node, IDofType dofType)
        {
            int localNodeIdx = element.Nodes.IndexOf(node);

            Debug.Assert(localNodeIdx != -1, "The element does not contain this node.");
            IReadOnlyList <IReadOnlyList <IDofType> > elementDofs = element.ElementType.DofEnumerator.GetDofTypesForMatrixAssembly(element);
            int localDofIdx = elementDofs[localNodeIdx].FindFirstIndex(dofType);
            int multNum     = elementDofs[localNodeIdx].Count;
            int dofIdx      = multNum * (localNodeIdx + 1) - (localDofIdx + 1);

            return(dofIdx);
        }
        /// <summary>
        /// The returned structure is a list with as many entries as the number of nodes of this element. Each entry contains
        /// a list with the dofs of the corresponding node. E.g. For node idx = 3, dof idx = 2 the IDof is result[3][2].
        /// </summary>
        /// <returns></returns>
        public IReadOnlyList <IReadOnlyList <IDofType> > GetNodalDofs()
        {
            var allDofs = new IDofType[Nodes.Count][];

            for (int i = 0; i < Nodes.Count; ++i)
            {
                var nodalDofs = new IDofType[2];
                nodalDofs[0] = StructuralDof.TranslationX;
                nodalDofs[1] = StructuralDof.TranslationY;
                allDofs[i]   = nodalDofs;
            }
            return(allDofs);
        }
 /// <summary>
 /// Enforces a displacement for the provided node.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="freedomDegree">The axis of the prescribed displacement.</param>
 /// <param name="signedMagnitude">The magnitude of the prescribed displacement with its sign.</param>
 public void ApplyPrescribedDisplacement(Node node, IDofType freedomDegree, double signedMagnitude)
 {
     if (signedMagnitude == 0.0)
     {
         node.Constraints.Add(new Constraint()
         {
             DOF = freedomDegree, Amount = 0.0
         });
     }
     else
     {
         throw new NotImplementedException("For now only 0 displacements are supported");
     }
 }
        public static void EmbeddedEBEinMatrix_DisplacementControl()
        {
            // Model creation
            var model = new Model();

            // Subdomains
            //model.SubdomainsDictionary.Add(subdomainID, new Subdomain() { ID = 1 });
            model.SubdomainsDictionary.Add(subdomainID, new Subdomain(subdomainID));

            // Variables
            int      monitorNode = 161;
            IDofType monitorDof  = StructuralDof.TranslationZ;

            // Choose model
            EmbeddedEBEModelBuilder.EmbeddedExampleBuilder(model);

            //-----------------------------------------------------------------------------------------------------------
            // Model

            // Choose linear equation system solver
            //var solverBuilder = new SkylineSolver.Builder();
            //SkylineSolver solver = solverBuilder.BuildSolver(model);
            var solverBuilder        = new SuiteSparseSolver.Builder();
            SuiteSparseSolver solver = solverBuilder.BuildSolver(model);

            // Choose the provider of the problem -> here a structural problem
            var provider = new ProblemStructural(model, solver);

            // Choose child analyzer -> Child: DisplacementControl
            var subdomainUpdaters    = new[] { new NonLinearSubdomainUpdater(model.SubdomainsDictionary[subdomainID]) };
            int increments           = 100;
            var childAnalyzerBuilder = new DisplacementControlAnalyzer.Builder(model, solver, provider, increments);
            DisplacementControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            // Choose parent analyzer -> Parent: Static
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Request output
            string outputFile = outputDirectory + "\\CNT-Embedded-3D_Results.txt";
            var    logger     = new TotalLoadsDisplacementsPerIncrementLog(model.SubdomainsDictionary[subdomainID], increments,
                                                                           model.NodesDictionary[monitorNode], monitorDof, outputFile);

            childAnalyzer.IncrementalLogs.Add(subdomainID, logger);

            // Run the analysis
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();
        }
示例#18
0
        public ConvectionDiffusionElement3D(IReadOnlyList <Node> nodes, IIsoparametricInterpolation3D interpolation,
                                            IQuadrature3D quadratureForStiffness, IQuadrature3D quadratureForMass,
                                            IGaussPointExtrapolation3D gaussPointExtrapolation, ConvectionDiffusionMaterial material)
        {
            this.material = material;
            this.GaussPointExtrapolation = gaussPointExtrapolation;
            this.Nodes         = nodes;
            this.Interpolation = interpolation;
            this.QuadratureForConsistentMass = quadratureForMass;
            this.QuadratureForStiffness      = quadratureForStiffness;

            dofTypes = new IDofType[nodes.Count][];
            for (int i = 0; i < interpolation.NumFunctions; ++i)
            {
                dofTypes[i] = new IDofType[] { ThermalDof.Temperature }
            }
            ;
        }
示例#19
0
        //TODO: It should not be stored at all. Instead we should be able to access the total prescribed displacement from the analyzer

        public TotalLoadsDisplacementsPerIncrementLog(Subdomain subdomain, int maxIncrementsExpected,
                                                      Node monitorNode, IDofType monitorDof, string outputFile)
        {
            this.subdomain   = subdomain;
            this.monitorNode = monitorNode;
            this.monitorDof  = monitorDof;

            isMonitorDofFree = true;
            foreach (Constraint constraint in monitorNode.Constraints) //TODO: use LINQ instead of this
            {
                if (constraint.DOF == monitorDof)
                {
                    isMonitorDofFree = false;
                    forceCalculator  = new ConstrainedDofForcesCalculator(subdomain);
                    break;
                }
            }

            this.outputFile = outputFile;
        }
        public ContinuumElement2D(double thickness, IReadOnlyList <Node> nodes, IIsoparametricInterpolation2D interpolation,
                                  IQuadrature2D quadratureForStiffness, IQuadrature2D quadratureForConsistentMass,
                                  IGaussPointExtrapolation2D gaussPointExtrapolation,
                                  IReadOnlyList <ElasticMaterial2D> materialsAtGaussPoints, DynamicMaterial dynamicProperties)
        {
            this.dynamicProperties       = dynamicProperties;
            this.materialsAtGaussPoints  = materialsAtGaussPoints;
            this.GaussPointExtrapolation = gaussPointExtrapolation;
            this.Nodes         = nodes;
            this.Interpolation = interpolation;
            this.QuadratureForConsistentMass = quadratureForConsistentMass;
            this.QuadratureForStiffness      = quadratureForStiffness;
            this.Thickness = thickness;

            dofTypes = new IDofType[nodes.Count][];
            for (int i = 0; i < nodes.Count; ++i)
            {
                dofTypes[i] = new IDofType[] { StructuralDof.TranslationX, StructuralDof.TranslationY };
            }
        }
示例#21
0
        //private readonly Dictionary<GaussPoint, ThermalMaterial> materialsAtGaussPoints;


        public ThermalElement2D(double thickness, IReadOnlyList <Node> nodes, IIsoparametricInterpolation2D interpolation,
                                IQuadrature2D quadratureForStiffness, IQuadrature2D quadratureForConsistentMass,
                                IGaussPointExtrapolation2D gaussPointExtrapolation,
                                ThermalMaterial material)
        {
            this.material = material;
            this.GaussPointExtrapolation = gaussPointExtrapolation;
            this.Nodes         = nodes;
            this.Interpolation = interpolation;
            this.QuadratureForConsistentMass = quadratureForConsistentMass;
            this.QuadratureForStiffness      = quadratureForStiffness;
            this.Thickness = thickness;

            dofTypes = new IDofType[nodes.Count][];
            for (int i = 0; i < interpolation.NumFunctions; ++i)
            {
                dofTypes[i] = new IDofType[] { ThermalDof.Temperature }
            }
            ;
        }
示例#22
0
        public ContinuumElement3DNonLinearDefGrad(IReadOnlyList <Node> nodes, IContinuumMaterial3DDefGrad material, IQuadrature3D quadratureForStiffness,
                                                  IIsoparametricInterpolation3D interpolation)
        {
            this.nGaussPoints           = quadratureForStiffness.IntegrationPoints.Count;
            this.QuadratureForStiffness = quadratureForStiffness;
            this.Interpolation          = interpolation;


            materialsAtGaussPoints = new IContinuumMaterial3DDefGrad[nGaussPoints];
            for (int i = 0; i < nGaussPoints; i++)
            {
                materialsAtGaussPoints[i] = (IContinuumMaterial3DDefGrad)material.Clone();
            }

            dofTypes = new IDofType[nodes.Count][];
            for (int i = 0; i < nodes.Count; i++)
            {
                dofTypes[i] = new IDofType[]
                {
                    StructuralDof.TranslationX, StructuralDof.TranslationY, StructuralDof.TranslationZ
                };
            }
        }
示例#23
0
        internal double CalculateForceAt(Node node, IDofType dofType, IVectorView totalDisplacements)
        {
            double totalForce = 0.0;

            foreach (Element element in node.ElementsDictionary.Values)
            {
                // It is possible that one of the elements at this node does not engage this dof type, in which case -1 will be returned.
                // We will not have any contribution from them. If none of the elements engage this dof type, the total force will always be 0.
                int monitorDofIdx = FindLocalDofIndex(element, node, dofType);
                if (monitorDofIdx == -1)
                {
                    continue;
                }

                //TODO: if an element has embedded elements, then we must also take into account their forces.
                double[] totalElementDisplacements = subdomain.CalculateElementDisplacements(element, totalDisplacements);
                double[] elementForces             = element.ElementType.CalculateForcesForLogging(element, totalElementDisplacements);

                totalForce += elementForces[monitorDofIdx];
            }

            return(totalForce);
        }
        private readonly IDofType[][] standardDofTypes; //TODO: this should not be stored for each element. Instead store it once for each Quad4, Tri3, etc. Otherwise create it on the fly.

        public XContinuumElement2D(int id, IReadOnlyList <XNode> nodes, IIsoparametricInterpolation2D interpolation,
                                   IGaussPointExtrapolation2D gaussPointExtrapolation, IQuadrature2D standardQuadrature,
                                   IIntegrationStrategy2D <XContinuumElement2D> integrationStrategy,
                                   IIntegrationStrategy2D <XContinuumElement2D> jIntegralStrategy, IMaterialField2D material)
        {
            this.id                      = id;
            this.Nodes                   = nodes;
            this.Interpolation           = interpolation;
            this.GaussPointExtrapolation = gaussPointExtrapolation;
            this.StandardQuadrature      = standardQuadrature;
            this.IntegrationStrategy     = integrationStrategy;
            this.JintegralStrategy       = jIntegralStrategy;
            this.Material                = material;

            this.NumStandardDofs = 2 * nodes.Count;
            standardDofTypes     = new IDofType[nodes.Count][];
            for (int i = 0; i < nodes.Count; ++i)
            {
                standardDofTypes[i] = new IDofType[] { StructuralDof.TranslationX, StructuralDof.TranslationY };
            }

            //OBSOLETE: Elements access their enrichments from nodes now.
            //this.EnrichmentItems = new List<IEnrichmentItem2D>();
        }
示例#25
0
        /// <summary>
        /// This method calculates the Pressure boundary condition when applied to a two-dimensional NURBS element.
        /// </summary>
        /// <param name="element">An element of type <see cref="NurbsElement2D"/>.</param>
        /// <param name="face">An two dimensional boundary entity. For more info see <see cref="Face"/>.</param>
        /// <param name="pressure"><inheritdoc cref="NeumannBoundaryCondition"/>.</param>
        /// <returns>A <see cref="Dictionary{TKey,TValue}"/> where integer values denote the degree of freedom that has a value double load value due to the enforcement of the <see cref="PressureBoundaryCondition"/>.</returns>
        public Dictionary <int, double> CalculateLoadingCondition(Element element, Face face, PressureBoundaryCondition pressure)
        {
            Contract.Requires(element != null, "The element cannot be null");
            Contract.Requires(face != null, "The face cannot be null");
            Contract.Requires(pressure != null, "The pressure boundary condition cannot be null");

            var dofs = new IDofType[] { StructuralDof.TranslationX, StructuralDof.TranslationY, StructuralDof.TranslationZ };

            IList <GaussLegendrePoint3D> gaussPoints =
                CreateElementGaussPoints(element, face.Degrees[0], face.Degrees[1]);
            Dictionary <int, double> pressureLoad = new Dictionary <int, double>();
            var     elementControlPoints          = element.ControlPoints.ToArray();
            Nurbs2D nurbs = new Nurbs2D(element, elementControlPoints, face);

            for (int j = 0; j < gaussPoints.Count; j++)
            {
                Matrix jacobianMatrix = Matrix.CreateZero(2, 3);
                double xGaussPoint    = 0;
                double yGaussPoint    = 0;
                double zGaussPoint    = 0;
                for (int k = 0; k < elementControlPoints.Length; k++)
                {
                    xGaussPoint          += nurbs.NurbsValues[k, j] * elementControlPoints[k].X;
                    yGaussPoint          += nurbs.NurbsValues[k, j] * elementControlPoints[k].Y;
                    zGaussPoint          += nurbs.NurbsValues[k, j] * elementControlPoints[k].Z;
                    jacobianMatrix[0, 0] += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].X;
                    jacobianMatrix[0, 1] += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].Y;
                    jacobianMatrix[0, 2] += nurbs.NurbsDerivativeValuesKsi[k, j] * elementControlPoints[k].Z;
                    jacobianMatrix[1, 0] += nurbs.NurbsDerivativeValuesHeta[k, j] * elementControlPoints[k].X;
                    jacobianMatrix[1, 1] += nurbs.NurbsDerivativeValuesHeta[k, j] * elementControlPoints[k].Y;
                    jacobianMatrix[1, 2] += nurbs.NurbsDerivativeValuesHeta[k, j] * elementControlPoints[k].Z;
                }

                Vector surfaceBasisVector1 = Vector.CreateZero(3);
                surfaceBasisVector1[0] = jacobianMatrix[0, 0];
                surfaceBasisVector1[1] = jacobianMatrix[0, 1];
                surfaceBasisVector1[2] = jacobianMatrix[0, 2];

                Vector surfaceBasisVector2 = Vector.CreateZero(3);
                surfaceBasisVector2[0] = jacobianMatrix[1, 0];
                surfaceBasisVector2[1] = jacobianMatrix[1, 1];
                surfaceBasisVector2[2] = jacobianMatrix[1, 2];

                Vector surfaceBasisVector3 = surfaceBasisVector1.CrossProduct(surfaceBasisVector2);

                double jacdet = (jacobianMatrix[0, 0] * jacobianMatrix[1, 1])
                                - (jacobianMatrix[1, 0] * jacobianMatrix[0, 1]);

                for (int k = 0; k < elementControlPoints.Length; k++)
                {
                    for (int m = 0; m < 3; m++)
                    {
                        int dofID = element.Model.GlobalDofOrdering.GlobalFreeDofs[elementControlPoints[k], dofs[m]];
                        if (pressureLoad.ContainsKey(dofID))
                        {
                            pressureLoad[dofID] += nurbs.NurbsValues[k, j] * jacdet * gaussPoints[j].WeightFactor *
                                                   pressure.Value * surfaceBasisVector3[m];
                        }
                        else
                        {
                            pressureLoad.Add(dofID,
                                             nurbs.NurbsValues[k, j] * jacdet * gaussPoints[j].WeightFactor * pressure.Value * surfaceBasisVector3[m]);
                        }
                    }
                }
            }

            return(pressureLoad);
        }
示例#26
0
 public GravityLoad(double density, double acceleration, IDofType dofType)
 {
     _density      = density;
     _acceleration = acceleration;
     _dofType      = dofType;
 }
        public static void EmbeddedCNTinMatrix_NewtonRaphson()
        {
            // No. of increments
            int increments = 1000;

            // Model creation
            var model = new Model();

            // Subdomains
            //model.SubdomainsDictionary.Add(subdomainID, new Subdomain() { ID = 1 });
            model.SubdomainsDictionary.Add(subdomainID, new Subdomain(subdomainID));

            // Variables
            int      monitorNode = 10001;
            IDofType monitorDof  = StructuralDof.TranslationZ;

            // Choose model
            EmbeddedModelBuilder.EmbeddedExample(model);

            // Boundary Conditions - Left End [End-1]
            for (int iNode = 1; iNode <= 100; iNode++)
            {
                model.NodesDictionary[iNode].Constraints.Add(new Constraint {
                    DOF = StructuralDof.TranslationZ
                });
            }

            // Boundary Conditions - Bottom End [End-3]
            for (int iNode = 1; iNode <= 10001; iNode += 100)
            {
                for (int j = 0; j < 10; j++)
                {
                    model.NodesDictionary[iNode + j].Constraints.Add(new Constraint {
                        DOF = StructuralDof.TranslationY
                    });
                }
            }

            // Boundary Conditions - Right End [End-5]
            for (int iNode = 1; iNode <= 10091; iNode += 10)
            {
                model.NodesDictionary[iNode].Constraints.Add(new Constraint {
                    DOF = StructuralDof.TranslationX
                });
            }

            //// Boundary Conditions - Left End [End-6]
            //for (int iNode = 10; iNode <= 10100; iNode += 10)
            //{
            //    model.NodesDictionary[iNode].Constraints.Add(new Constraint { DOF = DOFType.X });
            //}

            //Compression Loading
            double nodalLoad = -1.0;                         //0.40;

            for (int iNode = 10001; iNode <= 10100; iNode++) //[End-4]
            {
                model.Loads.Add(new Load()
                {
                    Amount = nodalLoad, Node = model.NodesDictionary[iNode], DOF = StructuralDof.TranslationZ
                });
            }

            // Choose linear equation system solver
            //var solverBuilder = new SkylineSolver.Builder();
            //SkylineSolver solver = solverBuilder.BuildSolver(model);
            var solverBuilder        = new SuiteSparseSolver.Builder();
            SuiteSparseSolver solver = solverBuilder.BuildSolver(model);

            // Choose the provider of the problem -> here a structural problem
            var provider = new ProblemStructural(model, solver);

            // Choose child analyzer -> Child: NewtonRaphsonNonLinearAnalyzer
            var childAnalyzerBuilder = new LoadControlAnalyzer.Builder(model, solver, provider, increments)
            {
                ResidualTolerance = 1E-03
            };
            LoadControlAnalyzer childAnalyzer = childAnalyzerBuilder.Build();

            // Choose parent analyzer -> Parent: Static
            var parentAnalyzer = new StaticAnalyzer(model, solver, provider, childAnalyzer);

            // Request output
            string outputFile = outputDirectory + "\\CNT-Embedded-3D_Results.txt";
            var    logger     = new TotalLoadsDisplacementsPerIncrementLog(model.SubdomainsDictionary[subdomainID], increments,
                                                                           model.NodesDictionary[monitorNode], monitorDof, outputFile);

            childAnalyzer.IncrementalLogs.Add(subdomainID, logger);

            // Run the analysis
            parentAnalyzer.Initialize();
            parentAnalyzer.Solve();
        }
 public double GetDisplacementAt(INode node, IDofType dofType) => displacements[watchedDofs[node, dofType]];
示例#29
0
 public ODEDomainLoad(ODEMaterial material, double load, IDofType dofType)
 {
     _material = material;
     _load     = load;
     _dofType  = dofType;
 }
示例#30
0
 public EnrichedDof(IEnrichmentFunction2D enrichment, IDofType standardDof)
 {
     this.Enrichment  = enrichment;
     this.StandardDof = standardDof;
 }