GRINS-0.8.0
composite_function.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 // This test is in libMesh now, but let's leave it in GRINS until
26 // we're sure that's working.
27 
28 // libMesh
29 #include "libmesh/composite_function.h"
30 #include "libmesh/const_function.h"
31 #include "libmesh/dense_vector.h"
32 
33 using namespace libMesh;
34 
35 int main( /*int argc, char* argv[]*/ )
36 {
37  std::vector<std::vector<unsigned int> > index_sets(4);
38  index_sets[0].resize(2);
39  index_sets[0][0] = 3;
40  index_sets[0][1] = 4;
41  index_sets[1].resize(3);
42  index_sets[1][0] = 0;
43  index_sets[1][1] = 1;
44  index_sets[1][2] = 2;
45  index_sets[2].resize(3);
46  index_sets[2][0] = 0;
47  index_sets[2][1] = 2;
48  index_sets[2][2] = 4;
49  index_sets[3].resize(5);
50  index_sets[3][0] = 5;
51  index_sets[3][1] = 1;
52  index_sets[3][2] = 3;
53  index_sets[3][3] = 6;
54  index_sets[3][4] = 7;
55 
56  CompositeFunction<libMesh::Real> composite_outer;
57 
58  {
59  CompositeFunction<libMesh::Real> composite_inner;
60  composite_inner.attach_subfunction
61  (ConstFunction<libMesh::Real>(1), index_sets[0]);
62  composite_inner.attach_subfunction
63  (ConstFunction<libMesh::Real>(2), index_sets[1]);
64  composite_outer.attach_subfunction
65  (composite_inner, index_sets[3]);
66 
67  libMesh::DenseVector<libMesh::Real> test_one(5);
68 
69  composite_inner(libMesh::Point(0), 0, test_one);
70 
71  if (test_one(0) != 2)
72  return 1;
73  if (test_one(1) != 2)
74  return 1;
75  if (test_one(2) != 2)
76  return 1;
77  if (test_one(3) != 1)
78  return 1;
79  if (test_one(4) != 1)
80  return 1;
81  }
82  composite_outer.attach_subfunction
83  (ConstFunction<libMesh::Real>(3), index_sets[2]);
84 
85  libMesh::DenseVector<libMesh::Real> test_two(8);
86  composite_outer(libMesh::Point(0), 0, test_two);
87 
88  if (test_two(0) != 3)
89  return 1;
90  if (test_two(2) != 3)
91  return 1;
92  if (test_two(4) != 3)
93  return 1;
94  if (test_two(5) != 2)
95  return 1;
96  if (test_two(1) != 2)
97  return 1;
98  if (test_two(3) != 2)
99  return 1;
100  if (test_two(6) != 1)
101  return 1;
102  if (test_two(7) != 1)
103  return 1;
104 
105  return 0;
106 }
int main()

Generated on Tue Dec 19 2017 12:47:29 for GRINS-0.8.0 by  doxygen 1.8.9.1