comparison src/interpolate.cc @ 268:61830a4f9ab9

Improve formatting
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 14 Aug 2014 12:26:55 +0200
parents 5e9b5bbdc56b
children
comparison
equal deleted inserted replaced
267:53039ac90368 268:61830a4f9ab9
35 @end deftypefn") 35 @end deftypefn")
36 { 36 {
37 37
38 int nargin = args.length (); 38 int nargin = args.length ();
39 octave_value retval; 39 octave_value retval;
40 40
41 if (nargin < 2 || nargin > 3 || nargout > 1) 41 if (nargin < 2 || nargin > 3 || nargout > 1)
42 print_usage (); 42 { print_usage (); }
43 else 43 else
44 { 44 {
45 if (! function_type_loaded) 45 if (! function_type_loaded)
46 { 46 {
47 function::register_type (); 47 function::register_type ();
69 { 69 {
70 name = args(0).string_value (); 70 name = args(0).string_value ();
71 offset = 1; 71 offset = 1;
72 } 72 }
73 73
74 if (args(1+offset).type_id () == functionspace::static_type_id ()) 74 if (args(1 + offset).type_id () == functionspace::static_type_id ())
75 { 75 {
76 const functionspace & u1 = 76 const functionspace & u1 =
77 static_cast<const functionspace&> (args(1+offset).get_rep ()); 77 static_cast<const functionspace &> (args(1 + offset).get_rep ());
78 78
79 if (! error_state) 79 if (! error_state)
80 { 80 {
81 SHARED_PTR <dolfin::Function> 81 SHARED_PTR <dolfin::Function>
82 output (new dolfin::Function (u1.get_pfsp ())); 82 output (new dolfin::Function (u1.get_pfsp ()));
83 83
84 if (args(0+offset).type_id () == function::static_type_id ()) 84 if (args(0 + offset).type_id () == function::static_type_id ())
85 { 85 {
86 const function & u0 = 86 const function & u0 =
87 static_cast<const function&> (args(0+offset).get_rep ()); 87 static_cast<const function &> (args(0 + offset).get_rep ());
88 88
89 if (! error_state) 89 if (! error_state)
90 { 90 {
91 try { output->interpolate (u0.get_fun ()); } 91 try { output->interpolate (u0.get_fun ()); }
92 catch (std::runtime_error &) 92 catch (std::runtime_error &)
94 error ("unable to interpolate on this function space"); 94 error ("unable to interpolate on this function space");
95 } 95 }
96 if (! error_state) 96 if (! error_state)
97 { 97 {
98 if (name.empty ()) 98 if (name.empty ())
99 name = u0.get_str (); 99 { name = u0.get_str (); }
100 retval = new function (name, output); 100 retval = new function (name, output);
101 } 101 }
102 } 102 }
103 } 103 }
104 else if (args(0+offset).type_id () == 104 else if (args(0 + offset).type_id () ==
105 coefficient::static_type_id ()) 105 coefficient::static_type_id ())
106 { 106 {
107 const coefficient & u0 = 107 const coefficient & u0 =
108 static_cast<const coefficient&> (args(0+offset).get_rep ()); 108 static_cast<const coefficient &> (args(0 + offset).get_rep ());
109 109
110 if (! error_state) 110 if (! error_state)
111 { 111 {
112 try { output->interpolate (* u0.get_expr ()); } 112 try { output->interpolate (* u0.get_expr ()); }
113 catch (std::runtime_error &) 113 catch (std::runtime_error &)
115 error ("unable to interpolate on this function space"); 115 error ("unable to interpolate on this function space");
116 } 116 }
117 if (! error_state) 117 if (! error_state)
118 { 118 {
119 if (name.empty ()) 119 if (name.empty ())
120 name = u0.get_str (); 120 { name = u0.get_str (); }
121 retval = new function (name, output); 121 retval = new function (name, output);
122 } 122 }
123 } 123 }
124 } 124 }
125 else 125 else
126 error ("interpolate: invalid arguments"); 126 { error ("interpolate: invalid arguments"); }
127 } 127 }
128 } 128 }
129 else if (args(1+offset).type_id () == function::static_type_id ()) 129 else if (args(1 + offset).type_id () == function::static_type_id ())
130 { 130 {
131 const function & u0 = 131 const function & u0 =
132 static_cast<const function&> (args(1+offset).get_rep ()); 132 static_cast<const function &> (args(1 + offset).get_rep ());
133 133
134 if (! error_state) 134 if (! error_state)
135 { 135 {
136 SHARED_PTR <dolfin::Function> 136 SHARED_PTR <dolfin::Function>
137 output (new dolfin::Function (u0.get_fun ())); 137 output (new dolfin::Function (u0.get_fun ()));
138 138
139 if (args(0+offset).type_id () == function::static_type_id ()) 139 if (args(0 + offset).type_id () == function::static_type_id ())
140 { 140 {
141 const function & u1 = 141 const function & u1 =
142 static_cast<const function&> (args(0+offset).get_rep ()); 142 static_cast<const function &> (args(0 + offset).get_rep ());
143 143
144 if (! error_state) 144 if (! error_state)
145 { 145 {
146 try { output->interpolate (u1.get_fun ()); } 146 try { output->interpolate (u1.get_fun ()); }
147 catch (std::runtime_error &) 147 catch (std::runtime_error &)
149 error ("unable to interpolate on this function space"); 149 error ("unable to interpolate on this function space");
150 } 150 }
151 if (! error_state) 151 if (! error_state)
152 { 152 {
153 if (name.empty ()) 153 if (name.empty ())
154 name = u1.get_str (); 154 { name = u1.get_str (); }
155 retval = new function (name, output); 155 retval = new function (name, output);
156 } 156 }
157 } 157 }
158 } 158 }
159 else if (args(0+offset).type_id () == 159 else if (args(0 + offset).type_id () ==
160 coefficient::static_type_id ()) 160 coefficient::static_type_id ())
161 { 161 {
162 const coefficient & u1 = 162 const coefficient & u1 =
163 static_cast<const coefficient&> (args(0+offset).get_rep ()); 163 static_cast<const coefficient &> (args(0 + offset).get_rep ());
164 164
165 if (! error_state) 165 if (! error_state)
166 { 166 {
167 try { output->interpolate (* u1.get_expr ()); } 167 try { output->interpolate (* u1.get_expr ()); }
168 catch (std::runtime_error &) 168 catch (std::runtime_error &)
170 error ("unable to interpolate on this function space"); 170 error ("unable to interpolate on this function space");
171 } 171 }
172 if (! error_state) 172 if (! error_state)
173 { 173 {
174 if (name.empty ()) 174 if (name.empty ())
175 name = u1.get_str (); 175 { name = u1.get_str (); }
176 retval = new function (name, output); 176 retval = new function (name, output);
177 } 177 }
178 } 178 }
179 } 179 }
180 else 180 else
181 error ("interpolate: invalid arguments"); 181 { error ("interpolate: invalid arguments"); }
182 } 182 }
183 } 183 }
184 else 184 else
185 error ("interpolate: invalid arguments"); 185 { error ("interpolate: invalid arguments"); }
186 } 186 }
187 return retval; 187 return retval;
188 } 188 }