COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-matrix-interpolation.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for SF interpolation in matrix form"
9 
10 #include <boost/assign/list_of.hpp>
11 #include <boost/test/unit_test.hpp>
12 
13 #include "common/Log.hpp"
14 
15 #include "math/MatrixTypes.hpp"
17 
19 #include "common/Table.hpp"
20 
21 using namespace boost::assign;
22 using namespace cf3;
23 using namespace cf3::common;
24 using namespace cf3::mesh;
25 using namespace cf3::mesh::LagrangeP1;
26 
28 
30 {
31 
32  typedef Triag2D ETYPE;
33 
34  const static Uint NDOF = ETYPE::nb_nodes;
35  const static Uint nbQdPts = 4;
36  const static RealVector4 xi_q;
37  const static RealVector4 eta_q;
38  const static RealVector4 w;
39 
42  {
43  boost::shared_ptr< Table<Real> > V (common::allocate_component< Table<Real> >("V"));
44  V->set_row_size(NDOF);
45  V->resize(nbQdPts);
46 
47  boost::shared_ptr< Table<Real> > dVdxi (common::allocate_component< Table<Real> >("dVdxi"));
48  dVdxi->set_row_size(NDOF);
49  dVdxi->resize(nbQdPts);
50 
51  boost::shared_ptr< Table<Real> > dVdeta (common::allocate_component< Table<Real> >("dVdeta"));
52  dVdeta->set_row_size(NDOF);
53  dVdeta->resize(nbQdPts);
54 
55  ETYPE::CoordsT ref_coord;
56  ETYPE::SF::ValueT values;
57  ETYPE::SF::GradientT gradients;
58  ETYPE::SF::ValueT dSFdxi;
59  ETYPE::SF::ValueT dSFdeta;
60 
61 
62  // Loop over quadrature points and set the elements of
63  // the generalized Vandermonde matrix and of the derivatives of
64  // the Vandermonde matrix
65  for(Uint iq=0;iq<nbQdPts;++iq) {
66  ref_coord[XX] = xi_q[iq];
67  ref_coord[YY] = eta_q[iq];
68 
69  ETYPE::SF::compute_value(ref_coord,values);
70  V->set_row<RealVector>(iq,values);
71 
72  ETYPE::SF::compute_gradient(ref_coord,gradients);
73  for(Uint i = 0; i<NDOF; ++i) {
74  dSFdxi[i] = gradients(XX,i);
75  dSFdeta[i] = gradients(YY,i);
76  }
77 
78  dVdxi->set_row<RealVector>(iq,dSFdxi);
79  dVdeta->set_row<RealVector>(iq,dSFdeta);
80 
81  }
82 
83  /*
84  //Some printouts:
85  //CFinfo << "Finished setting up the Vandermonde matrix" << CFendl;
86  for(Uint i=0; i<nbQdPts; ++i) {
87  Table<Real>::ConstRow row = (*V)[i];
88  for(Uint j=0; j<NDOF; ++j) {
89  CFinfo << row[j] << " ";
90  }
91  CFinfo << CFendl;
92  }
93  CFinfo << CFendl;
94 
95  //Print the derivatives with respect to xi:
96  for(Uint i=0; i<nbQdPts; ++i) {
97  Table<Real>::ConstRow row = (*dVdxi)[i];
98  for(Uint j=0; j<NDOF; ++j) {
99  CFinfo << row[j] << " ";
100  }
101  CFinfo << CFendl;
102  }
103  CFinfo << CFendl;
104 
105  //Print the derivatives with respect to eta:
106  for(Uint i=0; i<nbQdPts; ++i) {
107  Table<Real>::ConstRow row = (*dVdeta)[i];
108  for(Uint j=0; j<NDOF; ++j) {
109  CFinfo << row[j] << " ";
110  }
111  CFinfo << CFendl;
112  }
113  CFinfo << CFendl;
114  */
115 
116  } // constructor
117 
120  {
121  }
122 
123 };
124 
125 
127 const RealVector4 MatrixInterpolationFixture::xi_q(1.0/3.0, 0.2, 0.6, 0.2);
128 const RealVector4 MatrixInterpolationFixture::eta_q(1.0/3.0, 0.2, 0.2, 0.6);
129 const RealVector4 MatrixInterpolationFixture::w(-27.0/96.0, 25.0/96.0, 25.0/96.0, 25.0/96.0);
130 
132 
133 BOOST_FIXTURE_TEST_SUITE( MatrixInterpolationSuite, MatrixInterpolationFixture )
134 
135 
137 BOOST_AUTO_TEST_CASE( MyInterpolation )
138 {
139 }
140 
141 
143 
144 BOOST_AUTO_TEST_SUITE_END()
145 
146 
2D Lagrange P1 Triangular Element type This class provides the lagrangian shape function describing t...
Definition: Triag2D.hpp:36
BOOST_AUTO_TEST_CASE(MyInterpolation)
Definition: Defs.hpp:17
static const RealVector4 xi_q
Integration for P1 triangle, 4 quadrature points:
Basic Classes for Mesh applications used by COOLFluiD.
MatrixInterpolationFixture()
common setup for each test case
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealVector
Dynamic sized column vector.
Definition: MatrixTypes.hpp:25
namespace holding LagrangeP1 shape functions and elements
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Eigen::Matrix< Real, Triag2D_traits::dimension, 1 > CoordsT
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Eigen::Matrix< Real, 4, 1 > RealVector4
Fixed size 4x1 column vector.
Definition: MatrixTypes.hpp:42
Definition: Defs.hpp:17
~MatrixInterpolationFixture()
common tear-down for each test case
Most basic kernel library.
Definition: Action.cpp:19
boost::shared_ptr< T > allocate_component(const std::string &name)
Stand-alone function to allocate components of a given type.
Definition: Component.hpp:55
Send comments to:
COOLFluiD Web Admin