testtet10.cpp

00001 /*************************************************************************************
00002  * MechSys - A C++ library to simulate (Continuum) Mechanical Systems                *
00003  * Copyright (C) 2005 Dorival de Moraes Pedroso <dorival.pedroso at gmail.com>       *
00004  * Copyright (C) 2005 Raul Dario Durand Farfan  <raul.durand at gmail.com>           *
00005  *                                                                                   *
00006  * This file is part of MechSys.                                                     *
00007  *                                                                                   *
00008  * MechSys is free software; you can redistribute it and/or modify it under the      *
00009  * terms of the GNU General Public License as published by the Free Software         *
00010  * Foundation; either version 2 of the License, or (at your option) any later        *
00011  * version.                                                                          *
00012  *                                                                                   *
00013  * MechSys is distributed in the hope that it will be useful, but WITHOUT ANY        *
00014  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A   *
00015  * PARTICULAR PURPOSE. See the GNU General Public License for more details.          *
00016  *                                                                                   *
00017  * You should have received a copy of the GNU General Public License along with      *
00018  * MechSys; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
00019  * Fifth Floor, Boston, MA 02110-1301, USA                                           *
00020  *************************************************************************************/
00021 
00022 #include <iostream>
00023 
00024 #include "fem/fem.h"
00025 #include "fem/ele/tet10equilib.h"
00026 #include "linalg/vector.h"
00027 
00028 using std::cout;
00029 using std::endl;
00030 using LinAlg::Vector;
00031 
00032 int main(int argc, char **argv) try
00033 {
00034     /* {{{                        
00035      *                         t
00036      *                         |
00037      *                         |                                           
00038      *                         | 3                                         
00039      *                         @,                                          
00040      *                        /|`                                          
00041      *                        ||  `,                                       
00042      *                       / |    ',                                     
00043      *                       | |      \                                    
00044      *                      /  |       `.                                  
00045      *                      |  |         `,  9                             
00046      *                     /   @ 7         `@                              
00047      *                     |   |             \                             
00048      *                    /    |              `.                           
00049      *                    |    |                ',                         
00050      *                 8 @     |                  \                        
00051      *                   |     @.,,_       6       `.                      
00052      *                  |     / 0   ``'-.,,@_        `.                    
00053      *                  |    /              ``''-.,,_  ', 2                
00054      *                 |    /                        ``'@.,,,              
00055      *                 |   '                       ,.-``     ``''- s       
00056      *                |  ,@ 4                 _,-'`                        
00057      *                ' /                 ,.'`                             
00058      *               | /             _.@``                                 
00059      *               '/          ,-'`   5                                  
00060      *              |/      ,.-``                                          
00061      *              /  _,-``                                               
00062      *            .@ '`                                                    
00063      *           / 1                                                       
00064      *          /                                                          
00065      *         /                                                           
00066      *        r                                                            
00067      }}} */
00069     Array<REAL> sub_cam_prms;
00070     sub_cam_prms.push_back(0.0891); // lam
00071     sub_cam_prms.push_back(0.0196); // kap
00072     sub_cam_prms.push_back(0.20);   // nu
00073     sub_cam_prms.push_back(3.2);    // Rcs
00074     sub_cam_prms.push_back(5000);   // c
00075 
00077     Array<REAL>         ini_data;
00078     Array<Array<REAL> > ini_vals;
00079     ini_data.push_back(2);     // Svert
00080     ini_data.push_back(2);     // Shorz
00081     ini_data.push_back(2);     // Shorz
00082     ini_data.push_back(1.691); // v_ini (specific volume)
00083     ini_data.push_back(1);     // OCR
00084     ini_vals.push_back(ini_data);
00085 
00087     Array<FEM::Node> N;
00088     N.resize(10);
00089     N[0].Initialize(0,  0, 0, 0);
00090     N[1].Initialize(1, 10, 0, 0);
00091     N[2].Initialize(2,  0,10, 0);
00092     N[3].Initialize(3,  0, 0,10);
00093     N[4].Initialize(4,  5, 0, 0);
00094     N[5].Initialize(5,  5, 5, 0);
00095     N[6].Initialize(6,  0, 5, 0);
00096     N[7].Initialize(7,  0, 0, 5);
00097     N[8].Initialize(8,  5, 0, 5);
00098     N[9].Initialize(9,  0, 5, 5);
00099 
00101     FEM::Tet10Equilib E;
00102 
00103     // Setup element connectivity and nodal vars
00104     for (int i=0; i<10; ++i)
00105         E.SetNode(i, &N[i]);
00106 
00107     // Setup element model
00108     E.ReAllocateModel("SubCam", sub_cam_prms, ini_vals);
00109 
00111     
00112     // Temporary array of pointers to the nodes of the face {1,2,3, 5,9,8}
00113     Array<FEM::Node*> a_ptr_face_nodes;
00114     a_ptr_face_nodes.push_back( &N[1] );
00115     a_ptr_face_nodes.push_back( &N[2] );
00116     a_ptr_face_nodes.push_back( &N[3] );
00117     a_ptr_face_nodes.push_back( &N[5] );
00118     a_ptr_face_nodes.push_back( &N[9] );
00119     a_ptr_face_nodes.push_back( &N[8] );
00120 
00121     // Calculate the nodal values for face {1,2,3,5,9,8} according to the type of the correspondent element
00122     String       str_dof_name;
00123     Vector<REAL> a_nodal_values;
00124     E.CalcFaceNodalValues("tz"   ,   // In:  Face DOF Name, ex.: "tx, ty, tz"
00125                           -10    ,   // In:  Face DOF Value, ex.: 10 kPa, 20 kPa
00126                           a_ptr_face_nodes,   // In:  Array of ptrs to face nodes
00127                           str_dof_name    ,   // Out: Nodal DOF Name, ex.: "fx, fy, fz"
00128                           a_nodal_values  );  // Out: Vector of nodal values
00129 
00130     // Loop along the nodes of face {1,2,3,5,9,8}
00131     for (int m=0; m<6; ++m)
00132     {
00133         // Get a reference to a DOFVarsStruct
00134         FEM::Node::DOFVarsStruct & dof_var = a_ptr_face_nodes[m]->DOFVar(str_dof_name);
00135 
00136         // Setup Natural nodal variable
00137           dof_var.NaturalBry += a_nodal_values(m); // Upgrade (add) existent values
00138         dof_var.IsEssenPresc  = false;
00139     }
00140     
00142     
00143     cout << "str_dof_name = " << str_dof_name << endl;
00144     cout << "Vector of nodal values=\n" << a_nodal_values << endl;
00145 
00146     cout << "Nodes=\n";
00147     for (int i=0; i<10; ++i) cout << N[i];
00148 
00149     return 0;
00150 }
00151 catch (Exception * e)
00152 {
00153     e->Cout();
00154     if (e->IsFatal()) exit(1);
00155     delete e;
00156 }
00157 catch (char const * s)
00158 {
00159     cout << " Fatal:" << s << "\n";
00160     exit(1);
00161 }
00162 
00163 // vim:fdm=marker

Generated on Wed Jan 24 15:56:26 2007 for MechSys by  doxygen 1.4.7