ISAAR.MSolve.SamplesConsole/Preprocessing/PreprocessorModel.cs
/// <summary>
/// Adds a whole mesh, which is defined by its nodes and elements, to the model.
/// </summary>
/// <param name="nodes">The nodes of the mesh.</param>
/// <param name="elements">The elements of the mesh.</param>
/// <param name="material">The common material of all elements in the mesh.</param>
/// <param name="dynamicProperties">Optional material properties for dynamic analysis. Common for all elements in the 
///     mesh.</param>
Adds a whole mesh, which is defined by its nodes and elements, to the model.
Adds a whole mesh which is defined by its nodes and elements to the model .
public void AddMesh2D(IReadOnlyList<Node> nodes, IReadOnlyList<CellConnectivity<Node>> elements, 
            IFiniteElementMaterial material, DynamicMaterial dynamicProperties = null)
        {
            if (Dimensions == ProblemDimensions.ThreeDimensional)
            {
                throw new InvalidOperationException(
                    "This method can be used only for 2D problems (plane strain or plane stress)");
            }
            int numNodesCurrent = model.NodesDictionary.Count;
            for (int i = 0; i < nodes.Count; ++i) model.NodesDictionary.Add(numNodesCurrent + i, nodes[i]);
            int numElementsCurrent = model.Elements.Count;
            int numElementsSubdomain = model.Subdomains[0].Elements.Count;
            var factory = new ContinuumElement2DFactory(thickness, (ElasticMaterial2D)material, dynamicProperties); 
            for (int i = 0; i < elements.Count; ++i)
            {
                ContinuumElement2D element = factory.CreateElement(elements[i].CellType, elements[i].Vertices);
                var elementWrapper = new Element() { ID = numElementsCurrent + i, ElementType = element };
                foreach (Node node in element.Nodes) elementWrapper.AddNode(node);
                model.ElementsDictionary.Add(numElementsCurrent + i, elementWrapper);
                model.SubdomainsDictionary[0].Elements.Add(elementWrapper); 
            }
        }
public void AddMesh2D ( IReadOnlyList < Node > nodes , IReadOnlyList < CellConnectivity < Node > > elements , IFiniteElementMaterial material , DynamicMaterial dynamicProperties = null ) { if ( Dimensions == ProblemDimensions . ThreeDimensional ) { throw new InvalidOperationException ( " " ) ; } int numNodesCurrent = model . NodesDictionary . Count ; for ( int i = 0 ; i < nodes . Count ; ++ i ) model . NodesDictionary . Add ( numNodesCurrent + i , nodes [ i ] ) ; int numElementsCurrent = model . Elements . Count ; int numElementsSubdomain = model . Subdomains [ 0 ] . Elements . Count ; var factory = new ContinuumElement2DFactory ( thickness , ( ElasticMaterial2D ) material , dynamicProperties ) ; for ( int i = 0 ; i < elements . Count ; ++ i ) { ContinuumElement2D element = factory . CreateElement ( elements [ i ] . CellType , elements [ i ] . Vertices ) ; var elementWrapper = new Element ( ) { ID = numElementsCurrent + i , ElementType = element } ; foreach ( Node node in element . Nodes ) elementWrapper . AddNode ( node ) ; model . ElementsDictionary . Add ( numElementsCurrent + i , elementWrapper ) ; model . SubdomainsDictionary [ 0 ] . Elements . Add ( elementWrapper ) ; } }
Adds a whole mesh, which is defined by its nodes and elements, to the model.
Adds a whole mesh which is defined by its nodes and elements to the model .
// Nodes // Elements //TODO: extend the factory to other materials //TODO: let the user decide which subdomain it will be added to.
nodes
IReadOnlyList<Node>
The nodes of the mesh.
The nodes of the mesh .
elements
IReadOnlyList<CellConnectivity<Node>>
The elements of the mesh.
The elements of the mesh .
material
IFiniteElementMaterial
The common material of all elements in the mesh.
The common material of all elements in the mesh .
dynamicProperties
DynamicMaterial
Optional material properties for dynamic analysis. Common for all elements in the
mesh.
Optional material properties for dynamic analysis . Common for all elements in the mesh .