Full text
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales MASTER THESIS Adaptation of a library, to be released as free software, for the improvement of the finite element solution using the MLS-C recovery technique Presented by: D. Mohammed Ouallal Supervised by: Dr. Juan José Ródenas García and Dr. Enrique Nadal Soriano Valencia, April 2014
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 1 Acknowledgements First, I would like to express my sincere gratitude to my tutor Juanjo for his support, help several times and especially his patience during these months of work, and offer the opportunity for further research in this area, also thanks to him this work has been completed successfully. I want to thank Enrique who, besides being busy, he was able to attend and devote all the time.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 2 Resumen El objetivo principal de la tesis es adaptar una librería desarrollada en Matlab que implementa la tecnica de reconstrucción de tensiones MLS-C para que en el futuro pueda ser, bajo licencia GNU LGPL, de libre disposición para usuarios. La librería es una herramienta para evaluar los campos de tensiones recuperadas apartir de los resultados obtenidos por diferentes analisis numericos como el MEF o metodos sin malla. Para ilustrar el uso de la libreria MLS-C, se crearà una interface con el codigo comercial Ansys para que la libreria se llame directamente desde Ansys para postprocesar el campo discontinuo de tensiones en 2D proporcionado por este codigo. La librería presenta una alternativa de alta calidad al promediado nodal usado por Ansys para obtener campos continuos de tensiones. Para publicar la libreria MLS-C, hemos elegido la licencia GNU GPL introducida por Richard Stallman que a por objetivo dar a los usuarios la libertad de modificar, compartir, distribuir y redistribuir. En es tesis, la seccion 2 va a describir la licencia GNU, la seccion 3 va a presentar un resumen de la tecnica MLS-C. La seccion 4 describirà las subrutinas principales usada para la implementacion de la tecnica MLS-C en Matlab, y subrutinas creadas usando fichero macro de Ansys para llamar a la subrutina MLS. Seccion 5 presentarà ejemplos numericos ilustrativos. El material presente en esa tesis, de la seccion 2 a la seccion 5
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 3 se va a publicar bajo la licencia GNU. Finalemente, la seccion 6 presentarà la conclusion de este trabajo con un anexo con toda la subrutina implementada en Matlab en la seccion 8. Palabras clave: GNU LPGL, Moving Least Squares, Elementos finitos, reconstrucción, alisado
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 4 Abstract The main objective of this master thesis is to adapt a library developed in Matlab [4] which implements the MLS-C technique to make it freely available for other researchers as a tool to evaluate recovered stress fields from the results obtained with different numerical analysis techniques like the FEM or the meshless methods. To illustrate the use of this MLS-C library, an interface with the commercial code Ansys [5] will also be created so that the library can be directly invoked from Ansys to postprocess the discontinuous 2D stress fields provided by this code. This would then represent a high quality alternative technique to the nodal averaging technique used by Ansys to obtain continuous stress fields. We have choosen to publish the MLS-C library under the GNU General Public License [6]introduced by Richard Stallman which aims to give computer users the freedom to modify, share, and even distribute it again. In this thesis Section 2 will describe the GNU License, Section 3 will present a resume of the Moving Least Squares Recovery Technique with constraints (MLS-C)[3]. Section 4 will describe the main subroutines used for the Matlab implementation of the MLS-C technique and the subroutines created using the Ansys macros language to invoke the MLS- C subroutine. Section 5 will present illustrative numerical examples. Most of the material presented in this thesis in Sections 2 to 5 will be published together with the software under the GNU license. Finally Section 6 will present the conclusions of this work with an anex with all Matlab code in the section 8.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 5 Key words: GNU LPGL, Moving Least Squares, Finite elements, reconstruction, smoothing.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 6 Resum L'objectiu principal de la tesi és adaptar una llibreria desenrotllada en Matlab que implementa la tècnica de reconstrucció de tensions MLS-C perquè en el futur puga ser, baix llicència GNU LGPL, de lliure disposició per a usuaris. La llibreria és una ferramenta per a avaluar els camps de tensions recuperades apartir dels resultats obtinguts per diferents anàlisis numèriques com el MEF o fiquedos sense malla. Per a il·lustrar l'ús de la llibreria MLS-C, es crearà una interfície amb el codi comercial Ansys perquè la llibreria es cride directament des d'Ansys per a postprocesar el camp discontinu de tensions en 2D proporcionat per este codi. La llibreria presenta una alternativa d'alta qualitat a l'amitjanat nodal usat per Ansys per a obtindre camps continus de tensions. Per a publicar la llibreria MLS-C, hem triat la llicència GNU GPL introduïda per Richard Stallman que a per objectiu donar als usuaris la llibertat de modificar, compartir, distribuir i redistribuir. En és tesi, la secció 2 descriurà la llicència GNU, la secció 3 presentarà un resum de la tècnica MLS-C. La secció 4 describirà les subrutines principals usada per a la implementació de la tècnica MLS-C en Matlab, i subrutines creades usant fitxer macro d'Ansys per a cridar a la subrutina MLS. Secció 5 presentarà exemples numèrics il·lustratius. El material present en eixa tesi, de la secció 2 a la secció 5 es va a publicar davall la llicència GNU. Fina-liment, la secció 6 presentarà la conclusió d'este treball amb un annex amb tota la subrutina implementada en Matlab en la secció 8.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 7 Paraules clau: GNU LPGL, Moving Least Squares, Elements finits, reconstrucció, allisat"
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 7 2. GNU General Public License – GNU 2.1. What is the GNU? The GNU General Public License or GNU GPL is the most widely used license in the software world, guarantees to users as persons, organizations and companies, the freedom to use, study, share, copy and modify the software which is being published under the named license. Its purpose is to claim that the software covered by that license is free software and protect it of several appropriations which eventually could restrict these freedoms to users. The GPL GNU has been created originally by Richard Stallman, the founder of the Free Software Foundation (FSF) for the GNU project. Stallman define Free Software as “any program whose users enjoy of certain liberties” but beyond a specific concept, things that characterize the free software are the four basic freedoms which grant to the user: 1. Freedom to run the program to any purpose. 2. Freedom to study how the program works and change it so the user can do whatever he wants. This freedom allows the user “to modify the program according to his needs or convenience and use these modifications in a private manner ‘without claiming these modifications’”. 3. Freedom to reallocate copies so other can benefit of it. 4. Freedom to allocate copies of its modified versions to third.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 8 One of the software aspects which the computer law covers is the contractual field. Well so, into that category we find the contracts relative to the Software, one of them is the license, one of the central materials of this master thesis. A license is said to be Free Software when this “allows the users to use it freely in their use, reproduce, modify and distribute” (Bain, Gallego, Martínez Ribas y Rius [7]), i.e. that license which reflects the four basics freedoms of free software. We will analyze the GNU GPL “GNU general public license” which is determinative in the moment of establishment if the license is compatible or not. During 1980, the beginning of the GNU Project, the license “was linked to each program. Copying a license, changing its titles,… created compatibilities problems” (Vidal [8]). Facing that situation, Stallman debugged these particular licenses to create the version 1, which could benefit any developer to license his program (Vidal [8]). In the GPL, the granted rights reflect, obviously, the four fundamental freedoms of the Free Software: in its first clause the GNU GPL allows copying and distributing copies of the original source code, without modifications, which is freedom 2 of free software. Also allows modifying the program or part of it, i.e. the first freedom is also present in the GNU GPL. Besides, the license allows the distribution of the mentioned modifications, which corresponds to the freedom number 3. Finally the GNU GPL grants the right to copy and distribute the program,
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 9 with or without modifications, right corresponding to the freedom 2 and 3 of the free Software. As a corollary of the foregoing rights, the GNU GPL imposes certain conditions or restrictions. First, and with respect to the possibility of reproduce and distribute copies without modifying the program, the above license presents a series of requirements, being the most interesting the obligation to grant to the program recipients a copy of the license GPL along with the distributed software. In the second place, the GPL establish the requirements to accomplish in order to copy and distribute copies of the program with modifications. The most important between them is that the derived work has to be licensed as all and only under the same GNU GPL, this is strongly required. The Copyleft is considered a central element within the movement of the Free Software, “allows the execution of the program, its copy, modifications and distribution of modified versions, always that any kind of constraint is added a posteriori” (Stallman [10]) In the third point, and to copy and distribute the program (or its derived works), the GPL license requires (beside the accomplishment the anterior requirements) to give the source code of the program.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 10 2.2. Publishing under GNU License Things that we know so far about “Software license” are the terms the author determines (actually the holder of the right of exploitation) which must be respected in the moment of the distribution of copies. Speaking in roughly mode, there exist three principal characters in the software distribution: - The author/s of the works which is being distributed (person who wrote the program). - The copyright holder/s. - The user/s to which the program is destined. In the field of the free software, the author and the copyright holder are often the same person. The main difference between them, in Spain for example, is that authority of the work is irrevocable and unalienable (the author could not transfer to another person) while is the case for the copyright by means of contract. Anyway, it is the copyright holder concerned to determine the terms of the distribution. Let’s see how this works out, we have this simple example as follows: # helloworld.m – program says Hello World
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 11 In this simple case we don’t know who is the autor and the copyright holder. When this occurs, it doesn’t mean that you are not the author, neither the intellectual property law corves it. Conversely, you are the author in the moment of performing the work. By putting “Written by…” one could solve a lot of problem in the future. After we modify the program we obtain: # helloworld.m – program says Hello World # # Written by Author By including our name in the head of the program we do not obtain any additional right (the authority is inherent) but we do strengthen the legal form of our program: it is more difficult that other person pretends to be the author and includes his. We cannot see any copyright notification (Copyright (C)). Same thing occurs with the authority, and that doesn’t imply that exploitation right could not be ours: There is an implicit copyright notification in the anterior program which indicates that exploitation rights correspond to the author. Specify explicitly who is the master of the exploitation rights makes the work robust legally.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 12 # helloworld.m – program says Hello World # # Written by Author # Copyright (C) 1999 Author Now it is clearly and explicit who is the author and the copyright holder. In the following step we specify what are the conditions under the program is being distributed. This usually should be written under the copyright notification, as we have seen in many sites. What are these conditions? That depends on the intentions of the copyright holder. People whom distribute private software (non-free software) use these conditions to grant certain rights and deny others, like including the notification “all right reserved” and use licenses called EULA’s (End User License Agreement) to grant restricted rights to people who buy it. After, if we would like our program to be private, we could simply write: # helloworld.m – program says Hello World # # Written by Author # Copyright (C) 2005 Author # All rights reserved. If the author do not include: “All right reserved”, it doesn’t mean that this program is not private. Actually, if the distribution conditions are omitted, what law says is that all rights are reserved. By default none of the rights
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 13 is granted. This is very important: people tend to think that the programs found in the web which do not specify distribution rights, or do not include copyright notification, are in public domain, this is wrong. By default, the conditions are “all right reserved”, the copyright holder is the author as well, and the name of the author is not legally required to be mentioned. This was how the private software is published. We want our programs to be free. That means the users must enjoy the four freedoms of rights which we already mentioned in a previous section, freedoms maintained by the FSF (Free Software Foundation): - Right to execute the software, for any purpose. - Right to know how the program works and adapt it for one need. - Right to distribute copies of the programs. - Right to perform modifications and redistribute. Well, at first, we want the users of our programs enjoy all these rights. As we have seen already, we can use our role of copyright holder to grant these freedoms or rights to the users (conversely to the private software, where the copyright holder use to restrict it). So we can simply include:
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 14 # helloworld.m – program says Hello World # # Written by Author # Copyright (C) 2005 Author # Users of this software have the right to use it without restriction. Once this is written and the software distributed, users who got access to it will have the specified rights under copyright notification. However, one problem appears which it was experimented in the first years of the free software: people who write programs (they are also the copyright holders) are usually developers but not lawyers. The problem is that the conditions of exploitation which the developers wrote under the copyright notification would be legally weak. Lawyers know all of this, and in a text like the previous one, they would be able to find a lot of weak points, ambiguities and sentences with a possible double sense. In case of legal conflict, this could mean the loss of some rights. The solution was the following: Instead of every developer write his own distribution terms in their programs trying to follow the spirit of the definition of the free software, lawyers were paid in order to redact a text specifying these rights in a legally robust form. In that way, developers could copy under their copyright notification. This was the origin of the GPL license and other free license.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 15 It is important that we recognize the role of the free license: they are simply terms of exploitation well redacted. The way to proceed is very simple. We just have to take the previous example and insert the GPL text under the copyright notification, as follows: # helloworld.m – program says Hello World # # Written by Author # Copyright (C) 2005 Author # <INSERT THE GPL HERE> It is not an obligation to pay anyone or ask permission to use a free license. The specific free licenses are distributed under conditions of exploitation which allow its use without restriction. However, some free licenses are too long (as the GPL) and it is not very practical to repeat it in all and every project source file under the copyright notification.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 16 Let’s see an example using the GPL: /* * Software.m – Software Inc. (Software name or File name) * Copyright (C) (year) Author (the Copyright holder/ author) * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with GNU gv; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or see <http://www.gnu.org/licenses/>. * Author: * Internet: email address * Address: * Phone: * FAX: */
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 23 enhanced such as that, in the evaluation of * σ , we will consider equations being satisfied by the exact solution, i.e. the internal and boundary equilibrium equations. We will here describe the MLS-C technique, implemented in a MATLAB 1 library, used to evaluate the recovered stress fields for 2D linear elasticity problems solved with the Finite Element Method (FEM). This recovered stress field has two main uses: a) to improve the FE discontinuous stress solution, and b) to estimate the error in energy norm. The mathematical basis used to implement the subroutine can be found in J.J. Ródenas et al [1]. 3.2. MLS recovery The MLS technique is a method used for the reconstruction of continuous functions from a set of unorganized point samples via the calculation of a weighted least squares measure biased towards the region around the point at which the reconstructed value is requested. When the MLS technique is applied to recover a continuous stress field from FE discontinuous results, the components of the recovered stress vector around a given point )( *xσ , (i = xx, yy, xy) are obtained from a polynomial expansion, using the following expression: 1 The names of the main variables used in the subroutine are shown within brackets in the text or on the left hand side of the equations, using Courier New fonts so that the subroutine can be easily followed.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 24 FieldStGP )( *xσ pTerms )(xp Coefi )(xai )()()( *xaxpxσi (2) Where )(xp contains the terms of the polynomial and )(xai is the vector of polynomial unknown coefficients for the th i component of the stress field. For each stress components in the 2D case, assuming quadratic interpolation polynomials, we would have: 22 ,,,,1,)( yxyxyxxp (3) aaaaaa)( 543210 ,...,,,,, iiiiii ixa (4) )( )( )( )(00 0)(0 00)( )()( )( )( )( )( * * * * xa xa xa xp xp xp xAxP x x x xσ xy yy xx xy yy xx (5) The matrix form given by (5) will help us to impose the boundary and internal equilibrium in later calculations.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 25 Let χ be a point within the support denominated x corresponding to a point x defined by a radius x Ω R (RadProb). The MLS approximation is given by SIG )( χxσ, * x χχaχpχxσ )()(),( *ii (6) A continuous MLS approximation the following functional is used to obtain the unknown coefficients A . FieldFEGP )(xσh W )-( xW χχxσχxσχxx d,,)-()( 2 * h WJ (7) where W is the weighting function. The coefficients will be evaluated through the linear system )()()( xGxAxM where x χχPχPχxxM d)()()-()( T W (8) x hT χχσχPχxxG d)()()-(W)( (9) This equation can be numerically evaluated, considering n influence points within the support x , as follows;
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 26 NumInflPoints n l n lll h ll HW J 1 2 *)(,,)-( )( χJχxσχxσχx x (10) l n 1l lll T lHW )()()()-()( χJχPχPχxxM (11) l n 1l ll h l T lHW )()()()-()( χJχσχPχxxG (12) where )( l χJ is the Jacobian of the transformation between the global and the local coordinates and l H is the weight corresponding to point l χ The influence points are simply, the integration points used in the FE analysis falling into the inlfuence domain, where the FE stresses are known. The weighting function in the MLS subroutine implemented is: 1 if 0 1if 3861 )( 432 s ssss Wx (13)
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 27 where s is the normalized distance function expressed as; x χx Ω R s (14) 3.3. Satisfaction of the boundary equilibrium equation Constrain equations will be imposed to enforce the satisfaction of the boundary equilibrium equation. In the MLS technique the boundary will smoothly appear in the support of x when x gets closer to the boundary. The formulation must enforce the satisfaction of the boundary condition when x is on the boundary. In order to avoid discontinuities when approaching the boundary, the influence of the boundary conditions must also smoothly appear in the formulation. As described in J.J. Ródenas et al [1] the functional in (7) will be modified to account for the satisfaction of the boundary equilibrium equation using a so-called nearest point approach. This approach weights the satisfaction of this equation at the points j χ (within x) on the contours used to define the boundary closest to x. Figure 1 shows a case where 2 nearest points have to be considered because x is close to a corner on the boundary.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 28 Figure 1: MLS support with boundary conditions applied on the nearest points on the boundary. The recovered stress field ),( *χxσ can be expressed as ),( ~*χxσ in a local coordinate system aligned with the contour using a rotation matrix )(αr , where is the angle between the horizontal global axis x and the vector normal to the surface at j χ . This will help to simplify the consideration of the boundary equilibrium equation: PtRtSigt )( χxσ, ~* RStress )(αr )()()( χx,σrχxσ** α, ~ (15)
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 29 where the rotation matrix )(αr is given by: )2(cos)2(sin0.5)2(sin0.5 sincossin )2(sinsincos )( 222 22 ααα ααα ααα αr (16) The unknown coefficients A are evaluated solving a linear system of equations )()()( xGxAxM where the consideration of the boundary equilibrium leads to the following expressions: PtRtRP )()( j i ~ T i ~ j TχPrrχP PtRtSig )()( j ex i ~ T i ~ j TχPσrχP WBP )( j W ~χx NBC 1j ji ~ T i ~ j T j l n 1l lll T l W ~ HW )()()( )()()()()( χPrrχPχx χJχPχPχ-xxM (17) NBC 1j j ex i ~ T i ~ j T j l n 1l ll h l T l W ~ HχW )()()( )()()()()( χPσrχPχx χJσχPχ-xxG (18) where the weighting function )( j W ~χx used to consider the boundary equilibrium equation is given by:
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 30 1 if 0 1if386 1 )-( )( ~32 s ssss s s W Wj j χx χx (19) In this definition of the weighting factor )( j W ~χx , the term )( ~j Wχx is in charge of smoothly introducing the effect of the boundary equilibrium whereas the term 1/s has the effect of increasing the weight of the term used to consider the boundary equilibrium when j χx , i.e., when 0s . Note that s = 0 if x is on the boundary, hence 1/s = ∞ in (19), In this case, instead of using (19), the boundary equilibrium equation is strongly enforced using the Lagrange Multipliers technique. 3.4. Satisfaction of the internal equilibrium equation. The Lagrange Multipliers technique is used to impose the internal equilibrium equation given by: Sig * σ 0 bσ* (20) Considering (5), * σ will be given by: )()( *APAPσ (21)
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 31 where A is unknown. Differentiating )()()( xGxAxM we obtain: GAMAM )()( (22) The following expressions for the partial derivatives of * σ are obtained evaluating A from (22) and substituting in (21): Minv -1 M xxxx G PMA M PM Pσ11 * (23) yyyy G PMA M PM Pσ11 * (24) where, for example, for the partial derivatives with respect to x we will have: NBC jj i T i j j l n llll l W H W 1 ~~ T 1 T )()( )( ~ )()()( )( )( χPrrχP x χx χJχPχP x χx x xM (25) and
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 32 NBC jj ex i T i j j l n lll h l l W Hχ W 1 ~~ T 1 T )()( )( ~ )()()( )( )( χPσrχP x χx χJσχP x χx x xG (26) with x χx x χx s s WW ll )()( (27) x χx x χx s s W ~ W ~jj )()( (28) Differentiating x χx Ω R s with respect to x we obtain x s . All these terms allow us to evaluate (23) and (24) which will allow us to consider de constraint equation (20) using the Lagrange multipliers technique, leading to the following system of equations to be solved at each point where the recovered stresses have to be evaluated: D G λ A 0C CM T (29) where C and D are used to express the constraint equation to impose the
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 39 5. Numerical examples This sections shows numerical examples used to check the performance of the MLS-C library. For all models a plane strain condition is assumed. The meshes were composed by linear and quadratics triangles, and linear and quadratic quadrilaterals. Meshes with both, triangles and quadrilaterals have also been considered. Two geometries have been considered. The first one, represented in the following figure, corresponds to a cylinder under internal pressure 0.3 2e11E 100P 20b 5astrainPlain Figure 3: Thick-wall cylinder subjected to internal pressure
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 40 This problem has an analytical solution given by the following expressions. For a point of coordinates (x,y) we consider a yr b =k x y arctg x22 Radial diplacement: r b +r )2 - (1 1) - (k E ) + (1 p = u 2 2 r Stress in cylindric coordinates 1 - k ) + (1 p = ; r b + 1 1 - k p = ; r b - 1 1 - k p = 2 z 2 2 2 t 2 2 2 r Stress in Cartesian coordinates ·cossen· ·cos en·s= sen· ·cos= trxy 2 t 2 ry 2 t 2 rx The second example corresponds to the support loaded with a traction of 100MPa show in the following figure. Note that due to the symetry of the problem, only one half of it has been modeled.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 41 R Figure 4: Support
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 42 The following meshes have been used. Mesh for cylinder Mesh for support Figure 5: Meshes used in the numerical analyses
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 43 The following sections show the results obtained by Ansys and MLS-C technique for both problems. 5.1. Cylinder under internal pressure. Linear interpolation. Meshes with Triangular elements Ansys results MLS-C results r min = -80.6977 r max = -0.229693 r min = -100 r max = -0.665·10-6 Figure 6: Radial stress r (r min exact = -100, r max exact = 0 )
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 44 Ansys results MLS-C results t min = 13.0718 t max = 119.113 t min = 12.9006 t max =154.05 Figure 7: Hoop stress t (t min exact =13.33, t max exact =113.33) Ansys results MLS-C results VM min = 13.2032 VM max =170.334 VM min = 12.9006 VM max = 221.667 Figure 8: Von Mises stress vm (vm min exact =11.8509, vm max exact =184.771)
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 45 Ansys results MLS-C results SXmin=-77.9814 SXmax=118.224 SX min = -100 SX max = -127.257 Figure 9: Cartesian stress x (x min exact =-100, x max exact =113.33) Ansys results MLS-C results SY min = -79.0272 SY max = 118.94 SY min = -100 SY max = 125.697 Figure 10: Cartesian stress y (y min exact =-100, y max exact =113.33)
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 46 Ansys results MLS-C results SXY min=-95.8572 SXYmax=-0.231892 SXYmin=-126.413 SXYmax=0.417.10-6 Figure 11: Cartesian shear stress xy
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 47 Linear interpolation. Meshes with Quadrilateral elements Ansys Results MLS-C Results r min = -88.8869 r max = -0.229624 r min = -100 r max = 0.514.10-6 Figure 12: Radial stress r Ansys Results MLS-C Results t min = 13.2143 t max = 110.763 t min = -13.0771 t max = 116.646 Figure 13: Hoop stress t
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 48 Ansys results MLS-C Results VM min = 13.3306 VM max = 171.06 VM min = 13.0771 VM max = 187.805 Figure 14: Von Mises stress VM
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 55 Quadratic interpolation. Meshes with Quadrilateral and Triangular elements Ansys results MLS-C results r min = -95.5859 r max = 0.09498 r min = -100 r max = 0.167.10-6 Figure 24: Radial stress r Ansys results MLS-C results t min = 13.4287 t max = 109.576 t min = 13.3738 t max = 117.508 Figure 25: Hoop stress t
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 56 Ansys results MLS-C results VM min = 13.4764 VM max = 177.813 VM min = 13.3738 VM max = 188.571 Figure 26: Von Mises stress VM Ansys results MLS-C results SX min = -92.0642 SX max = 105.535 SX min = -100 SX max = 110.333 Figure 27: Cartesian stress x
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 57 Ansys results MLS-C results SY min = -92.0642 SY max = 105.535 SY min = -100 SY max = 110.478 Figure 28: Cartesian stress y Ansys results MLS-C results SXYmin= -102.581 SXYmax=-0.070687 SXYmin=-106.797 SXYmax=0.455.10-13 Figure 30: Cartesian Shear stress xy Results discussion
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 58 The results clearly show that the results provided by the MLS-C technique are more accurate than the results directly provided by Ansys. The distribution of the stress fields is smoother with the MLS-C technique. The minimum and maximum values of stresses are more accurately evaluated with the MLS-C technique. 5.2. Support For the support we have: Linear interpolation. Ansys results MLS-C results SX min = -544.897 SX max = 418.916 SX min = -664.369 SX max = 479.771 Figure 31: Cartesian stress x
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 59 Ansys results MLS-C results SY min = -232.872 SY max = 680.89 SY min = -329.98 SY max = 801.247 Figure 32: Cartesian stress y Ansys results MLS-C results SXYmin=-401.586 SXYmax=244.764 SXY min = -487.014 SXY max = 337.209 Figure 33: Cartesian shear stress xy
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 60 Ansys results MLS-C results VMmin=6.48891 VMmax=894.627 VMmin = 9.15775 VMmax = 1074.62 Figure 34: Von Mises stress VM
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 61 Quadratic interpolation. Ansys results MLS-C results SX min = -656.02 SX max = 573.358 SX min = -698.064 SX max = 514.222 Figure 35: Cartesian stress x Ansys results MLS-C results SYmin = -389.251 SYmax = 778.739 SYmin = -324.128 SYmax = 825.448 Figure 36: Cartesian stress y
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 62 Ansys results MLS-C results SXYmin =-476.142 SXYmax =328.919 SXYmin =-509.332 SXYmax =365.664 Figure 36: Cartesian shear stress xy Ansys results MLS-C results VMmin = 9.65304 VMmax = 1057.59 VMmin = 5.78102 VMmax = 1113.49 Figure 37: Von Mises stress VM We can clearly see from the figures that the MLS-C results are smoother than those provided by Ansys. In any case it is difficult to see which
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 63 results are more accurate. To chech the accuracy we have plotted the stresses along some of the sides of the support (left and right vertical sides and lower and upper arc) as we know that the tractions along these free surfaces are zero. In addition the tractions on the lower segment must be equal to the applied traction of 100 MPa. The following figures compare, as an example of the performance of the MLS-C library, the stresses along the left vertical side and along the upper arc, with the results obtained as the direct output of Ansys.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 64 Figure 38: Comparing Stresses at vertical right side of the support for linear interpolation -2,50E+01 -2,00E+01 -1,50E+01 -1,00E+01 -5,00E+00 0,00E+00 5,00E+00 1,00E+01 0,00E+00 5,00E+00 1,00E+01 1,50E+01 2,00E+01 Stresses Distance Sx Sxy -2,50E+01 -2,00E+01 -1,50E+01 -1,00E+01 -5,00E+00 0,00E+00 5,00E+00 1,00E+01 0,00E+00 5,00E+00 1,00E+01 1,50E+01 2,00E+01 Stresses Distance Sx Sxy
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 71 [10] Stallman, Software libre para una sociedad libre. Madrid: Traficantes de Sueños (2004). [11] http://en.wikipedia.org/wiki/Affero_General_Public_License [12] https://www.gnu.org (Why you shouldn't use the Lesser GPL for your next library)
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 72 8. Annex In this section we will post all function we have already mentioned in the latter section involved in the recovery process. First the Ansys macro used to invoque the MLS-C library is described. Afterwards the rest of the subroutines are shown. In this case we have used the output of the Matlab Publishing tools to show this files in a more convinient way than the plain text files used when writing the code. This annex also includes the text of the GNU LGPL. 8.1. GNU LGPL Terms Version 3, 29 June 2007 Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License. “The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 73 An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”. The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 74 b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 75 d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interfacecompatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 76 a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. 8.2. Commercial software adaptation. Ansys
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 77 The input variables used in the MLS function implemented in MATLAB are obtained by generating a simple example of application in Ansys in .txt format. These files are cleaned by removing all headers and blanks spaces and only contain needed data. A .mac (macro) files are used to obtain the results (input variables) and to visualize the recovered stress field. The first one is called MLSRecovery_1.mac
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 78 ! --------------------------------------------------------- ! Define format for output data. ! Define Page layout: defile a huge number of lines so that all data fits ! within one page,5000 characters per line so that the stresses of each ! point fit within one line,-1 removes headers in batch mode [/BATCH], ! Diverted [/OUTPUT], or interactive GUI [/MENU] output. ! Remove the header lines. ! --------------------------------------------------------- /FORMAT,10,E,20,12 /PAGE,10000000,5000,-1,5000 /HEADER,OFF,OFF,OFF,OFF,OFF,OFF ! -------------------------------------------------------------------- ! Create output in .txt files with the FE results for the MLS subroutine. ! PRESOL contains the stresses at nodes of each element, whose values have been substituted by the stress values at Gauss points. The smoothing subroutine will have to take this information and locate it back at its original position: the Gauss points. ! NLIST (x,y) nodal coordinates ! ELIST Element's topology (nodes included in each element) ! --------------------------------------------------------- ! Create PRESOL /OUTPUT,.\PRESOL.txt PRESOL,S,COMP /OUTPUT /OUTPUT,.\NLIST.txt NLIST,,,,COORD /OUTPUT /OUTPUT,.\ELIST.txt ELIST /OUTPUT ! --------------------------------------------------------- ! From Ansys, open Matlab and run the QuadraticElms code. ! --------------------------------------------------------- /SYS,matlab -noFigureWindows -r "try; run('QuadraticElems.m'); catch; end;"
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 79 8.3. QuadraticElems.m This Matlab subroutine calls the MLS function to evaluate a recovered stress field from a 2D stress field evaluated using the finite element method for quadratic elements. A similar subrutine called LinearElems.m is used to deal with linear elements. %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* This Matlab(c) subroutine calls the Moving Least Squares function to evaluate a recovered stress field from a 2D stress field evaluated using the finite element method for quadratic elements. % Remove all blanck lines and headers from the output files (Element % solution, Topology, Node Coordinates) generated by Ansys to be used as % input argument when calling the MLS subroutine. AnsysRelease = 14; %Valid releases are 12 and 14
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 80 Read NLIST.txt Nodal information f = fopen('NLIST.txt', 'rt'); if AnsysRelease ==14 c = textscan(f,'%s','Delimiter','%s','headerlines',4,... 'CollectOutput',true); %Read file lines = c{1}; %Store nodal coords elseif AnsysRelease == 12 c = textscan(f,'%s','Delimiter','%s','headerlines',3,... 'CollectOutput',true); %Read file lines = c{1}; %Store nodal coords lines(1:21:end) = []; %Remove blank lines else err ('Ansys release not supported'); end fclose(f); coordinatesXY = zeros(numel(lines),4); for i = 1:numel(lines) coordinatesXY(i,:) = coordinatesXY(i,:) + str2num(lines{i}); end coordinatesXY(:,[1,4]) = []; Xcoord = coordinatesXY(:,1); Ycoord = coordinatesXY(:,2); Read ELIST.txt Element information f = fopen('ELIST.txt','rt'); if AnsysRelease ==14 c = textscan(f,'%s','Delimiter','%s','headerlines',4,... 'CollectOutput',true); lines = c{1}; elseif AnsysRelease == 12 c = textscan(f,'%s','Delimiter','%s','headerlines',2,... 'CollectOutput',true); lines = c{1}; lines(1:21:end) = []; else
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 87 Quadratic_SigXY(i,j) = FieldStGP_Quad_Node(topology(i,j),3); end end Quadratic_SigZ = zeros(size(topology,1),size(topology,2)); Quadratic_SigXZ = zeros(size(topology,1),size(topology,2)); Quadratic_SigYZ = zeros(size(topology,1),size(topology,2)); % Prepare the input argument for the CreateMacroToGetMLSdata function OutputXYZ = [coordinatesXY zeros(length(coordinatesXY),1)]; OutputTopology = unique(topology(:,1:4)); ShowUX = zeros(length(OutputTopology),1); ShowVY = zeros(length(OutputTopology),1); ShowSX = Quadratic_SigX(:,1:4); ShowSY = Quadratic_SigY(:,1:4); ShowTXY = Quadratic_SigXY(:,1:4); ShowSZ = Quadratic_SigZ(:,1:4); ShowTXZ = Quadratic_SigXZ(:,1:4); ShowTYZ = Quadratic_SigYZ(:,1:4); CreateMacroToGetMLSdata(ShowUX,ShowVY,OutputXYZ,topology(:,1:4),ShowSX,Sho wSY,ShowSZ,ShowTXY,ShowTXZ,ShowTYZ)
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 88 8.4. MLS.m function This is the main subroutine of the MLS-C library %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function [FieldStGP]= MLS( FieldFEGP,XYZGP,XYZout ) This Matlab(c) subroutine uses a Moving Least Squares approach to evaluate a recovered stress field from a 2D stress field evaluated using the finite element method. The mathematical basis used to create this subroutine can be found in Ródenas JJ, González-Estrada OA., Fuenmayor FJ, Chinesta F. Enhanced error estimator based on a nearly equilibrated moving least squares recovery technique for FEM and XFEM. Computational Mechanics. 52(2), 321-344 (2013). A basic description of this subroutine can be found in the file MLStechnique.pdf.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 89 INPUT AND OUTPUT %--------------------------------------------------------------------- % INPUT VARIABLES % FieldFEGP = FE stresses at sampling (integration) points % XYZGP = Coordinates of the sampling (integration) points % XYZout = Coordinates of the points where the recovered stress % field has to be evaluated % OUTPUT VARIABLES % FieldStGP = Reecovered stresses at XYZout % % MAIN INTERNAL VARIABLES RESHAPE INPUT DATA Input data is reshaped if needed because the code needs the data stored in columns if size(FieldFEGP,2)> size(FieldFEGP,1) FieldFEGP = FieldFEGP'; end if size(XYZGP,2)>size(XYZGP,1) XYZGP = XYZGP'; end if size(XYZout,2)>size(XYZout,1) XYZout = XYZout'; end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 90 DEFINITION OF SUBROUTINE PARAMETERS % Load geometry data stored in text files GeoPoints.txt and Boundaries.txt % ------------------------------------------------------------------------ load('GeoPoints.txt'); load('Boundaries.txt'); % Internal codes % -------------- BoundImpTract =40; % Boundary node with known % Normal and Tang stresses Symmetry =41; % Symmetry BC IntEquil = 1; % Internal equilibrium FIE = 1; % Full internal equilibrium ContourEquilWprime = 1; % Contour equilibrium TolBundary = 1e-10; % Tolerance for bound. conditions % Used to check if a point is over % a node on the boundary % General configuration % --------------------- Noc = size(FieldFEGP,2); % Number of field components DrawSupport = 0; % Flag 0 plot / 1 do not plot % support of each point SubSizes = [3,6,10,15,21,28]; % Size of equation system for each % polynomial degree of recovered % stress field MaxFieldDegree = 3; % Degree of the recovered field NumGP = size(XYZGP,1); % Total number of points in XYZGP Numout = size(XYZout,1); % Total number of points in XYZout NumInflPoints = 151; % Number of influence points in % the support disp(['The number of influence points considered in the support is: '... num2str(NumInflPoints) '.']) MinDegree = 100; % Keep polynomial expansion degree used % for each GP. CondNum = zeros(NumGP,1); % Initilize the number of GP verctor.
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 91 ERROR ESTIMATION EQUATIONS The ZZ error estimator will be evaluated as follows: The recovered stress field components are obtained from a polynomial expansion, using the following expression: For each stress components in the 2D case we have: MAXIMUM INFLUENCE RADIUS ASSUMING UNIFORM SAMPLING POINTS DISTRIBUTION Now, the MLS technique considers a point in a support denominated corresponding to a point defined by a radius . So the MLS approximation is given by: XMin = min(XYZGP(:,1)); XMax = max(XYZGP(:,1)); YMin = min(XYZGP(:,2)); YMax = max(XYZGP(:,2)); RadProb = sqrt((XMax-XMin)^2 + (YMax-YMin)^2)/2; Area = pi() * RadProb^2; PointDensity = NumGP / Area; MaxRadInf = sqrt(4*NumInflPoints/(PointDensity * pi())); disp(['The influence radius is: ' num2str(MaxRadInf) ... ' and the problem radius is: ' num2str(RadProb)]);
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 92 MSL LOOP AND DEFINITION OF EQUATIONS TO OBTAIN THE RECOVERED FIELD. In order to obtain the recovered stress field we have to solve the linear system of equations so we can get the vector of coefficient . % Initilize output matrix % ----------------------- FieldStGP = zeros(Numout,Noc); Auxds = zeros(Numout,1); for iGP = 1:Numout Initialize variables in case Lagrange for boundary Madd = []; % Main part of the system matrix Cadd = []; % Constraint equations Evaluation of points within the support of the assembly point % Find influence GP. % ------------------- XYPt = XYZout(iGP,:); % Coordinates of the assembly GP if NumGP <= NumInflPoints InflPoints = 1:NumGP; else dummyXGP = (XYZGP(:,1)-XYPt(1)); dummyYGP = (XYZGP(:,2)-XYPt(2)); dummyRadXYZGP = sqrt(dummyXGP.^2 + dummyYGP.^2); SuitablePoints = find(dummyRadXYZGP <= MaxRadInf); [~,I] = sort(dummyRadXYZGP(SuitablePoints),'ascend');
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 93 if length(I) > NumInflPoints % Find number of influence points InflPoints = SuitablePoints(I(1:NumInflPoints)); else InflPoints = SuitablePoints(I); end end NSP = length(InflPoints); % Number of sampling points ds = max(sqrt((XYZGP(InflPoints,1)-XYPt(1)).^2 +... (XYZGP(InflPoints,2)-XYPt(2)).^2));% Influence radius Auxds(iGP) = ds; There are sampling points of coordinates within the support using the FE analysis where the stresses are already available. The normalized distance function is given to calculate the weighting function: % Local coordinates of the influence points % ----------------------------------------- X = (XYZGP(InflPoints,1) - XYPt(1))/ds; Y = (XYZGP(InflPoints,2) - XYPt(2))/ds; S = sqrt(X.^2 + Y.^2); % Check if the AssGP support in in contact with any boundary % ---------------------------------------------------------- [BoundPts,AngleBoundPts,tBoundPts,BoundNum,NodeType,NBP]... = ClosestPointsOnBoundrs(XYPt(1),XYPt(2),ds,GeoPoints,Boundaries); % Local coordinates of the influence points on the boundaries. % ------------------------------------------------------------ XBP = ( BoundPts(:,1)-XYPt(1) )/ds; YBP = ( BoundPts(:,2)-XYPt(2) )/ds;
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 94 % Distance to the boundary points. % -------------------------------- SBP = ( XBP.^2 + YBP.^2 ).^0.5; % Draw support and influence points % --------------------------------- if DrawSupport ==1 figure; hold on; PlotGeo hold on; rectangle('Position',[XYPt(1)-ds,XYPt(2)-ds,2*ds,2*ds],... 'Curvature',[1,1]); plot(XYPt(1),XYPt(2),'bo'); plot(XYZGP(InflPoints,1),XYZGP(InflPoints,2),'r.'); if NBP~=0 plot(BoundPts(:,1),BoundPts(:,2),'kO'); end hold off axis equal pause; end The weighting function has been taken as the fourth-order spline, commonly used in the MLS related literature: % Evaluate the Weighting Function % ------------------------------- S2 = S.*S; W = (1 - 6*S2 + 8*S2.*S - 3*S2.*S2); W(W<0) = 0; % needed due to round-off errors % Create PatchMatrices and impose constraint equations. % ----------------------------------------------------- if IntEquil dummy = (-12+24*S-12*S.^2); Diameter = ds; dWdx = dummy.*X/Diameter^2; dWdy = dummy.*Y/Diameter^2; end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 95 WpFactor = 1; The boundary equilibrium must be satisfied at each point along the contour and in order to obtain a continuous recovered stress field the nearest point approach is used. Being NBP the number of points on the boundary where the constraints are imposed (see MLStechnique.pdf) In that case, the weighting function is defined as: % Evaluate the Weighting Function in Boundaries % --------------------------------------------- if ContourEquilWprime && NBP > 0 WBP = abs(1./SBP - 6*SBP + 8*SBP.^2 - 3*SBP.^3)*WpFactor; if IntEquil dummy = (-1./SBP.^3 - 6./SBP + 16 - 9*SBP)*WpFactor; dWBPdx = dummy.*XBP/Diameter^2; dWBPdy = dummy.*YBP/Diameter^2; end end % Evaluate Degree of interpolation polynomial in patch. % ----------------------------------------------------- % Remember that SubSizes = [3,6,10,15,21,28]; Degree = MaxFieldDegree; while NSP<SubSizes(Degree) Degree = Degree-1; end if Degree < 1 disp... ('Not enough sampling points. Please reconsider the discretization'); end SubMSize = SubSizes(Degree); MinDegree(iGP) = Degree;
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 96 Prepare data for M and G matrices for internal and boundary equ. Before getting through the imposition of the boundary and internal equilibrium equations, we prepare the equation system for M and G % Prepare data for M and G matrices % --------------------------------- [pTerms] = polininterp2d(X,Y,Degree); RowOfOnes = ones(1,SubMSize); TotalSize = SubMSize*Noc; M = zeros(TotalSize,TotalSize); % Internal equilibrium case. % ************************** if IntEquil; dMdx = M; dMdy = M; end % Create original system of equations % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ W1 = W * RowOfOnes; pTermsTr = pTerms'; pTermsTrW = pTermsTr.*W1'; Wptp = pTermsTr*(pTerms.*W1); G = [pTermsTrW*FieldFEGP(InflPoints,1);... pTermsTrW*FieldFEGP(InflPoints,2);... pTermsTrW*FieldFEGP(InflPoints,3)]; % Loop over field components % ~~~~~~~~~~~~~~~~~~~~~~~~~~ for iNoc=1:Noc Index = SubMSize*(iNoc-1)+1; M(Index:Index+SubMSize-1,Index:Index+SubMSize-1)... = Wptp; end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 103 8.5. Press.m This subroutine is used to define the pressure to be applied on the boundaries. This subroutine must be adapted by the user in each of the problems analyzed. %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function [txty,tntt]=press(Curve,t,x,y,Angle) % INPUT DATA: %------------------ % Curve - Id. Curve (internal ID) % t - relative position of the point within the Curve % x & y - x and y global coordinates of the point % Angle - Angle of the normal to the surface at points % % OUTPUT DATA: %------------------ % txty - will be a 2x1 vector where: % txty(1) = tx % txty(2) = ty %
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 104 %*************************************************************** GlobalCS=1; %the tractions will be specified as {tx,ty} LocalCS=0; %the tractions will be specified as {tn,tt} %note: use t>0 for tractions and t<0 for compressions switch Curve %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ % The user can make changes to define the pressure on boundary, % from here... % Different examples are given to define the pressure for each curve. case 1 CS=LocalCS; tn=-100; tt= 0; % case 2 % CS=GlobalCS; % tx=-100; % ty= 0; % case 3 % CS=LocalCS; % tn=-100*t; % tt= 0*t; % case 3 % CS=LocalCS; % tn=-100*y; % tt= 0*t; % to here. %@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ otherwise CS=GlobalCS; tx=0; ty=0; end % Change the coordinate system to global
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 105 if CS==LocalCS tntt=[tn;tt]; txty =[cos(-Angle),sin(-Angle);-sin(-Angle),cos(-Angle)]*tntt; elseif CS==GlobalCS [txty]=[tx;ty]; tntt =[cos(Angle),sin(Angle);-sin(Angle),cos(Angle)]*txty; end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 106 8.6. VolLoads.m This subroutine is used to define the voulume loada pressure to be applied. This subroutine must be adapted by the user in each of the problems analyzed. %******************************************************************** % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function [b]=VolLoads(XY,E,nu) %============================================ % Returns Loads per unit volume applied at XY %============================================ if size(XY,1)~=2 XY = XY'; end NumOfPoints = size(XY,2); b = []; x = XY(1,:); y = XY(2,:); b = [0;0]*ones(1,NumOfPoints);
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 107 8.7. CreateMacroToGetMLSdata.m This subroutine is used to create the file MLSresults.mac that will be used to load the results in the Ansys database. %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function CreateMacroToGetMLSdata(ShowUX,ShowVY,OutputXYZ,OutputTopology,ShowSX,Show SY,ShowSZ,ShowTXY,ShowTXZ,ShowTYZ) % THIS FUNCTION IS USED TO CREATE THE ANSYS MACRO CONTAINING THE RECOVERED % STRESS FIELD OBTAINED BY THE MLSCX TECHNIQUE. % INPUT VARIABLES %===================================================================== % ShowUX,ShowVY,ShowWZ NODE DISPLACEMENTS IN U, V and W DIRECTION. % OutputXYZ NODE COORDINATES. % OutputTopology MESH TOPOLOGY. % ShowSX,ShowSY,ShowSZ,... % ShowTXY,ShowTXZ,ShowTYZ STRESS COMPONENTS. fid = fopen('MLSresults.mac','wt'); % 'wt' means "write text"
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 108 if (fid < 0) error('could not open file "MLSresults.mac"'); end formatSpec ='/PREP7 \n'; fprintf(fid, formatSpec); formatSpec ='ET,1,PLANE182 \n'; fprintf(fid, formatSpec); % List of nodes coordinates formatSpec ='N , %4u , %4.16f, %4.16f, %4.16f \n'; for i=1:size(OutputXYZ,1) fprintf(fid, formatSpec,i,OutputXYZ(i,1),OutputXYZ(i,2)... ,OutputXYZ(i,3)); end % List for nodes per element formatSpec ='EN , %4u , %4u , %4u , %4u , %4u \n'; for i=1:size(OutputTopology,1) fprintf(fid,formatSpec,i,OutputTopology(i,1),OutputTopology(i,2)... ,OutputTopology(i,3),OutputTopology(i,4)); end % Data introduced to postprocess formatSpec ='MP,EX,1,1 \n'; fprintf(fid, formatSpec); formatSpec ='MP,NUXY,1,0.3 \n'; fprintf(fid, formatSpec); formatSpec ='D,ALL,ALL \n'; fprintf(fid, formatSpec); formatSpec ='SAVE \n'; fprintf(fid, formatSpec); formatSpec ='FINI \n'; fprintf(fid, formatSpec); formatSpec ='/SOLUTION \n'; fprintf(fid, formatSpec);
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 109 formatSpec ='SOLVE \n'; fprintf(fid, formatSpec); formatSpec ='FINISH \n'; fprintf(fid, formatSpec); formatSpec ='/POST1 \n'; fprintf(fid, formatSpec); % List of dispacements formatSpec ='DNSOL , %4u, U, X, %4u \n'; for i=1:numel(ShowUX) fprintf(fid, formatSpec,i,ShowUX(i)); end formatSpec ='DNSOL , %4u, U, Y, %4u \n'; for i=1:numel(ShowVY) fprintf(fid, formatSpec,i,ShowVY(i)); end % List of stresses formatSpec ='DESOL , %4u, %4u, S, X, %4u \n'; for i=1:size(ShowSX,1) for j=1:size(ShowSX,2) fprintf(fid, formatSpec,i,OutputTopology(i,j),ShowSX(i,j)); end end formatSpec ='DESOL , %4u, %4u, S, Y, %4u \n'; for i=1:size(ShowSY,1) for j=1:size(ShowSX,2) fprintf(fid, formatSpec,i,OutputTopology(i,j),ShowSY(i,j)); end end formatSpec ='DESOL , %4u, %4u , S, Z, %4u \n'; for i=1:size(ShowSZ,1) for j=1:size(ShowSZ,2) fprintf(fid, formatSpec,i,OutputTopology(i,j),ShowSZ(i,j)); end end formatSpec ='DESOL , %4u, %4u , S, XY, %4u \n'; for i=1:size(ShowTXY,1) for j=1:size(ShowTXY,2) fprintf(fid, formatSpec,i,OutputTopology(i,j),ShowTXY(i,j));
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 110 end end formatSpec ='DESOL , %4u, %4u , S, XZ, %4u \n'; for i=1:size(ShowTXZ,1) for j=1:size(ShowTXZ,2) fprintf(fid, formatSpec,i,OutputTopology(i,j),ShowTXZ(i,j)); end end formatSpec ='DESOL , %4u, %4u , S, YZ, %4u \n'; for i=1:size(ShowTYZ,1) for j=1:size(ShowTYZ,2) fprintf(fid, formatSpec,i,OutputTopology(i,j),ShowTYZ(i,j)); end end formatSpec ='/GRAPHICS,FULL \n'; fprintf(fid, formatSpec); fclose(fid); end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 111 8.8. Auxiliary functions This is a set of auxiliary functions required by the previous subroutines. Pgauss.m This subroutines is used to obtain the local coordinates of the Gauss integration points %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function [Coordinates,Weights]=... pgauss(Dimensions,NumSideElem,NumPoints,PointClass) % CALCULATION OF GAUSS POINTS COORDIANTES AND WEIGHTS FOR % VERTEX TRIANGLES (0,0),(1,0),(0,1) % AND VERTEX QUADRILATERAL (-1,-1),(-1,1), (1,1) (1,-1) % % % INPUT % Dimensions 1 Countour integral / 2 Integral area
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 112 % NumSideElem Number of side per element % NumPoints Number of total integration points per element % PointClass Set of integration points which being taken. % Used to diferentiate quadrature rules with % equal number of integration points % % OUTPUT % Coordinates Integration points coordinates in the local system. % Weights Weigth of each inegration point. %========================================================================= = if exist('PointClass')==0 PointClass=1; end %CONTOUR INTEGRAL %================ if Dimensions==1 switch NumPoints % Polynomial exact integration of degree P=1 %------------------------------------------- case 1 Coordinates = 0; Weights = 2; % Polynomial exact integration of degree P=3 %------------------------------------------- case 2 Coordinates = [... -0.577350269189626;... 0.577350269189626]; Weights = [1,1]'; % Polynomial exact integration of degree P=5 %------------------------------------------- case 3 Coordinates =[... -0.774596669241483;... 0;... 0.774596669241483]; Weights =[...
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 119 0.22908540422399;... 0.27228653255075;... 0.22908540422399;... 0.11340000000000;... 0.05613434886243;... 0.11340000000000;... 0.13478507238752;... 0.11340000000000;... 0.05613434886243]; otherwise disp (['Not implemented for quadrilateral area '... 'NumPoints = ',num2str(NumPoints)]); error('Stopping'); end %------------------------------------------------------------------ otherwise disp ([' A ',num2str(NumSideElem),... ' side element was specified which will not be used']); error('Stopping'); end end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 120 polininterp2d.m This subroutine creates a 2D polynomial expansion for a point of coordinates (x,y). %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function [P,dPdx,dPdy]=polininterp2d(X,Y,Degree,DerivFlag) %INPUT % X and Y are global coordinates % Degree : the polinomial degree % DeriveFlag: Flag used to indicate if derivatives of the polynomial % respect to the global coordinates system must be % evaluated. % % OUTPUT % % P : the polynomial % dPdx : Polynomial first derivative with respect to x component % dPdy : Polynomial first derivative with respect to y component
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 121 % Evaluate the matrix of vectors used as interpolation polinomial if size(X,2)>size(X,1) X = X'; Y = Y'; end if nargin<4 % if ~exist('DerivFlag','var') DerivFlag = 0; end C1 = ones (length(X),1); %Column of Ones C0 = zeros(length(X),1); %Column of Zeros % Calculate the polynomial for each degree and its derivatives. switch Degree case 1 % first polynomial degree P = [... C1 , ... X ,Y]; if DerivFlag dPdx = [... C0 , ... C1 , C0]; dPdy = [... C0 , ... C0 , C1]; end case 2 % second polynomial degree P = [... C1 , ... X , Y ,... X.*X, X.*Y, Y.*Y]; if DerivFlag dPdx = [... C0 , ... C1 , C0 , ... 2*X , Y , C0]; dPdy = [... C0 , ... C0 , C1 , ... C0 , X , 2*Y]; end case 3 % third polynomial degree
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 122 X2 = X.*X; XY=X.*Y; Y2=Y.*Y; P = [... C1 , ... X , Y ,... X2 , XY , Y2 ,... X2.*X , X2.*Y , X.*Y2 , Y.*Y2]; if DerivFlag dPdx = [... C0 , ... C1 , C0 , ... 2*X , Y , C0 , ... 3*X2 , 2*X.*Y , Y2 , C0]; dPdy = [... C0 , ... C0 , C1 , ... C0 , X , 2*Y , ... C0 , X2 , 2*X.*Y , 3*Y2]; end case 4 % fourth polynomial degree X2 = X.*X; XY=X.*Y; Y2=Y.*Y; X3 = X2.*X; X2Y=X2.*Y; XY2=X.*Y2; Y3=Y.*Y2; P = [... C1 , ... X , Y ,... X2 , XY , Y2 ,... X3 , X2Y , XY2 , Y3 ,... X3.*X , X3.*Y , X2.*Y2 , X.*Y3 , Y3.*Y]; if DerivFlag dPdx = [... C0 , ... C1 , C0 , ... 2*X , Y , C0 , ... 3*X2 , 2*X.*Y , Y2 , C0 , ... 4*X3 , 3*X2.*Y , 2*X.*Y2 , Y3 , C0 ]; dPdy = [... C0 , ... C0 , C1 , ... C0 , X , 2*Y , ... C0 , X2 , 2*X.*Y , 3*Y2 , ... C0 , X3 , 2*X2.*Y , 3*X.*Y2 , 4*Y3]; end case 5 % fifth polynomial degree X2 = X.*X;
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 123 XY = X.*Y; Y2 = Y.*Y; X3 = X2.*X; X2Y = X2.*Y; XY2 = X.*Y2; Y3 = Y.*Y2; X4 = X2.*X2; X3Y = X3.*Y; X2Y2 = X2.*Y2; XY3 = X.*Y3; Y4 = Y3.*Y; P = [... C1 , ... X , Y ,... X2 , XY , Y2 ,... X3 , X2Y , XY2 , Y3 ,... X4 , X3Y , X2Y2 , XY3 , Y4 ,... X4.*X , X4.*Y , X3.*Y2 , X2.*Y3 , X.*Y4 , Y4.*Y]; if DerivFlag dPdx = [... C0 , ... C1 , C0 , ... 2*X , Y , C0 , ... 3*X2 , 2*X.*Y , Y2 , C0 , ... 4*X3 , 3*X2.*Y , 2*X.*Y2 , Y3 , C0 , ... 5*X4 , 4*X3.*Y , 3*X2.*Y2 , 2*X.*Y3 , Y4 , C0 ]; dPdy = [... C0 , ... C0 , C1 , ... C0 , X , 2*Y , ... C0 , X2 , 2*X.*Y , 3*Y2 , ... C0 , X3 , 2*X2.*Y , 3*X.*Y2 ,4*Y3 , ... C0 , X4 , 2*X3.*Y , 3*X2.*Y2 ,4*X.*Y3 ,5*Y4]; end otherwise % error displays no results for Degree > 5 err(['Degree' num2str(Degree)... 'not implemented in PatchMatricesUStar']); end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 124 Shape_f_2d.m Obtains the shape functions for 2 dimensions. %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function [N,dNpsi,dNeta]=shape_f_2d(Coor,Degree,NumSideElem,CaldN) % Shape Function and its derivatives in a point for triangles and % quadrilaterals in local coordinates X=psi y Y=eta % % IMPORTANT: Node enumeration was made that way: % vertex node are first, then midside nodes. % % INPUT % Coor = coordinates (X = psi e Y = eta) % Degree = Element degree % NumSideElem = Number of side per elements (1, 3 & 4) % CaldN = Derivatives of N % 0 ==> no derivative % else ==> derivative takes place % OUTPUT % N = Shape function matrix. Each row corresponds to the
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 125 % shape function in a coordinate points (x,y) % dNpsi = Shape function matrix derivatives with respect to psi % dNeta = Shape function matrix derivatives with respect to eta if nargin==3 CaldN = 0; end X = Coor(:,1)'; Y = Coor(:,2)'; switch NumSideElem TRIANGLES case switch Degree case 1 % Linear elements N = [... 1-X-Y;... X;... Y]; if CaldN==0 dN = 0; else dN = [... -1+0.*X,-1+0.*X;... +1+0.*X, 0+0.*X;... 0+0.*X, 1+0.*X]; end case 2 % Quadratics elements N =[... (1-X-Y).*(1-2*X-2*Y);... -X.*(1-2*X);... -Y.*(1-2*Y);... 4*X.*(1-X-Y);... 4*X.*Y;... 4*Y.*(1-X-Y)]; if CaldN==0
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 126 dN = 0; else dN = [... -3+4*X+4*Y , -3+4*X+4*Y;... -1+4*X , 0.*X ;... +0.*X , -1+4*Y ;... +4-8*X-4*Y , -4*X ;... +4*Y , 4*X ;... -4*Y , +4-4*X-8*Y]; end otherwise % Superior degree triangles disp(['Polynomial degree ' num2str(Degree)... 'for triangles not implemented']); error('Stop'); end QUADRILATERALS case 4 switch Degree case 1 % Linears N = [... (1-Y).*(1-X)/4;... (1-Y).*(1+X)/4;... (1+Y).*(1+X)/4;... (1+Y).*(1-X)/4]; if CaldN==0 dN = 0; else dN = [... (-1+Y)/4, (-1+X)/4;... (+1-Y)/4, (-1-X)/4;... (+1+Y)/4, (+1+X)/4;... (-1-Y)/4, (+1-X)/4]; end case 2 % Quadratics N = [... -(1-Y).*(1-X).*(1+X+Y)/4 ;... -(1-Y).*(1+X).*(1-X+Y)/4 ;... -(1+Y).*(1+X).*(1-X-Y)/4 ;...
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 127 -(1+Y).*(1-X).*(1+X-Y)/4 ;... +(1-X.^2).*(1-Y)/2 ;... +(1-Y.^2).*(1+X)/2 ;... +(1-X.^2).*(1+Y)/2 ;... +(1-Y.^2).*(1-X)/2 ]; if CaldN==0 dN = 0; else dN = [... -(-1+Y).*(Y+2*X)/4 , -(-1+X).*(X+2*Y)/4 ;... -(-1+Y).*(-Y+2*X)/4 , -(1+X).*(X-2*Y)/4 ;... +(Y+1).*(Y+2*X)/4 , +(1+X).*(X+2*Y)/4 ;... -(Y+1).*(Y-2*X)/4 , -(-1+X).*(-X+2*Y)/4 ;... -X.*(1-Y) , +(-1+X.^2)/2 ;... +(1-Y.^2)/2 , -Y.*(1+X) ;... -X.*(Y+1) , +(1-X.^2)/2 ;... +(-1+Y.^2)/2 , -Y.*(1-X) ]; end otherwise % Superior degree quadrilaterals disp([ num2str(Degree) 'Polynomial degree not programmed for quadrilaterals']); error('Stopping'); end otherwise disp ([num2str(NumSideElem),... ' Side per element showed up. it will not be used ']); error('Stopping'); end N = N'; dN = dN'; if CaldN ~= 0 dNpsi = dN(1:size(Coor,1),:); dNeta = dN(size(Coor,1)+1:end,:); else dNpsi = []; dNeta = []; end return;
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 128 RotationMatrices.m This subroutines is used to obtain the rotation matrix and for the system transformation. %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* function [RCoord,RStress]=RotationMatrices(Alpha,Dims) % Evaluates rotation matrices for Coordinates and Stresses (or Stains) % so that if we calculate % Results = RMatrix*Data % Then Results are expressed in a refference system rotated Alpha rads % with respect to the coordinates system used to express Data % Note: Alpha could be a vector. This could be used for rotations in 3-D % % INPUT % Alpha = The angle of rotation % Dims = Dimensions % % OUTPUT % RCoord = The coordinate rotation matrix % RStress = The stress rotation matrix
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 135 function plot_arc(XY1,XY2,XYC,ClockWise) This function is used to plot arcs of circumference given the starting and end points, the center of the circumference and the sense to go from the starting to the end point XY1 = coordinates of starting point XY2 = coordinates of ending point XYC = coordinates of the center of the arc nsegments = 50; if ClockWise>=0; ClockWise=1; else ClockWise=0; end Cart1=XY1-XYC; Cart2=XY2-XYC; % [Th1,Rad1]=cart2pol(Cart1(1),Cart1(2)); [Th2,Rad2]=cart2pol(Cart2(1),Cart2(2)); if abs(Rad1-Rad2)>100*eps error (['Rad1 ~= Rad2']); end %The general case (does not require any adjustment) is: % ((Th1<Th2) && ~ClockWise) || ((Th2<Th1) && ClockWise) %Special cases if ((Th1<Th2) && ClockWise) Th2=Th2-2*pi(); elseif ((Th2<Th1) && ~ClockWise) Th2=Th2+2*pi(); end th = Th1:(Th2-Th1)/nsegments:Th2; xunit = Rad1 * cos(th) + XYC(1); yunit = Rad1 * sin(th) + XYC(2); plot(xunit, yunit); end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 136 PlotGeo.m This script is implemented to plot the geometry we work on %********************************************************************* % This file is part of the MLS-C© Library; you can redistribute it and/or % modify it under the terms of the GNU Lesser General Public License as % published by the Free Software Foundation; either version 3 of the % License,or any later version. % This program is distributed in the hope that it will be useful but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General % Public License for more details. % You should have received a copy of the GNU Lesser General Public License % along with GNU; see the file COPYING. If not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA % or see <http://www.gnu.org/licenses/>. %********************************************************************* % Created by: % E Nadal, M Ouallal, JJ Rodenas, F Chinesta and FJ Fuenmayor % % Release 1.0 % Date: 18/07/2014 %********************************************************************* figure hold on axis equal for i=1:size(Boundaries,1) if Boundaries(i,3)==0 Points=Boundaries(i,1:2); XYPoints=GeoPoints(Points,:); line(XYPoints(:,1),XYPoints(:,2)); elseif Boundaries(i,3)>=0 Points=Boundaries(i,1:2); XYPoints=GeoPoints(Points,:); XYCenter=GeoPoints(Boundaries(i,3),:); plot_arc(XYPoints(1,:),XYPoints(2,:),... XYCenter,Boundaries(i,4)); end end
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 137
UNIVERSITAT POLITÈCNICA DE VALÈNCIA Departamento de Ingeniería Mecánica y de Materiales Máster en Ingeniería Mecánica y Materiales 138