| 1 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
// vi: set et ts=4 sw=2 sts=2: |
| 3 |
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 4 |
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 5 |
#ifndef DUNE_REFINED_P1_LOCALBASIS_HH |
| 6 |
#define DUNE_REFINED_P1_LOCALBASIS_HH |
| 7 |
|
| 8 |
/** \file |
| 9 |
\brief Linear Lagrange shape functions on a uniformly refined reference element |
| 10 |
*/ |
| 11 |
|
| 12 |
#include <numeric> |
| 13 |
|
| 14 |
#include <dune/common/fmatrix.hh> |
| 15 |
|
| 16 |
#include <dune/localfunctions/refined/common/refinedsimplexlocalbasis.hh> |
| 17 |
|
| 18 |
namespace Dune |
| 19 |
{ |
| 20 |
template<class D, class R, int dim> |
| 21 |
class RefinedP1LocalBasis |
| 22 |
: public RefinedSimplexLocalBasis<D,dim> |
| 23 |
{ |
| 24 |
public: |
| 25 |
RefinedP1LocalBasis() |
| 26 |
{ |
| 27 |
DUNE_THROW(Dune::NotImplemented,"RefinedP1LocalBasis not implemented for dim > 3."); |
| 28 |
} |
| 29 |
}; |
| 30 |
|
| 31 |
/** |
| 32 |
\brief Uniformly refined linear Lagrange shape functions in 1D. |
| 33 |
|
| 34 |
This shape function set mimics the P1 shape functions that you would get on |
| 35 |
a uniformly refined grid. Hence these shape functions are only piecewise |
| 36 |
linear! The data layout is identical to P2 shape functions. |
| 37 |
|
| 38 |
Shape functions like these are necessary for hierarchical error estimators |
| 39 |
for certain nonlinear problems. |
| 40 |
|
| 41 |
The functions are associated to points by: |
| 42 |
|
| 43 |
f_0 ~ (0.0) |
| 44 |
f_1 ~ (0.5) |
| 45 |
f_2 ~ (1.0) |
| 46 |
|
| 47 |
\tparam D Type to represent the field in the domain. |
| 48 |
\tparam R Type to represent the field in the range. |
| 49 |
|
| 50 |
\nosubgrouping |
| 51 |
* \ingroup LocalFunctionsImpl |
| 52 |
*/ |
| 53 |
template<class D, class R> |
| 54 |
class RefinedP1LocalBasis<D,R,1> |
| 55 |
: public RefinedSimplexLocalBasis<D,1> |
| 56 |
{ |
| 57 |
public: |
| 58 |
//! \brief export type traits for function signature |
| 59 |
typedef LocalBasisTraits<D,1,Dune::FieldVector<D,1>,R,1,Dune::FieldVector<R,1>, |
| 60 |
Dune::FieldMatrix<R,1,1> > Traits; |
| 61 |
|
| 62 |
//! \brief number of shape functions |
| 63 |
static constexpr unsigned int size () |
| 64 |
{ |
| 65 |
return 3; |
| 66 |
} |
| 67 |
|
| 68 |
//! \brief Evaluate all shape functions |
| 69 |
inline void evaluateFunction (const typename Traits::DomainType& in, |
| 70 |
std::vector<typename Traits::RangeType>& out) const |
| 71 |
{ |
| 72 |
out.resize(3); |
| 73 |
|
| 74 |
int subElement; |
| 75 |
typename Traits::DomainType local; |
| 76 |
this->getSubElement(in, subElement, local); |
| 77 |
|
| 78 |
switch (subElement) { |
| 79 |
case 0 : |
| 80 |
|
| 81 |
out[0] = 1 - local[0]; |
| 82 |
out[1] = local[0]; |
| 83 |
out[2] = 0; |
| 84 |
break; |
| 85 |
|
| 86 |
case 1 : |
| 87 |
|
| 88 |
out[0] = 0; |
| 89 |
out[1] = 1 - local[0]; |
| 90 |
out[2] = local[0]; |
| 91 |
break; |
| 92 |
|
| 93 |
} |
| 94 |
|
| 95 |
} |
| 96 |
|
| 97 |
//! \brief Evaluate Jacobian of all shape functions |
| 98 |
inline void |
| 99 |
evaluateJacobian (const typename Traits::DomainType& in, // position |
| 100 |
std::vector<typename Traits::JacobianType>& out) const // return value |
| 101 |
{ |
| 102 |
out.resize(3); |
| 103 |
|
| 104 |
int subElement; |
| 105 |
typename Traits::DomainType local; |
| 106 |
this->getSubElement(in, subElement, local); |
| 107 |
|
| 108 |
switch (subElement) { |
| 109 |
case 0 : |
| 110 |
|
| 111 |
out[0][0][0] = -2; |
| 112 |
out[1][0][0] = 2; |
| 113 |
out[2][0][0] = 0; |
| 114 |
break; |
| 115 |
|
| 116 |
case 1 : |
| 117 |
|
| 118 |
out[0][0][0] = 0; |
| 119 |
out[1][0][0] = -2; |
| 120 |
out[2][0][0] = 2; |
| 121 |
break; |
| 122 |
|
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
//! \brief Evaluate partial derivatives of all shape functions |
| 127 |
void partial (const std::array<unsigned int, 1>& order, |
| 128 |
const typename Traits::DomainType& in, // position |
| 129 |
std::vector<typename Traits::RangeType>& out) const // return value |
| 130 |
{ |
| 131 |
auto totalOrder = order[0]; |
| 132 |
if (totalOrder == 0) { |
| 133 |
evaluateFunction(in, out); |
| 134 |
} else if (totalOrder == 1) |
| 135 |
{ |
| 136 |
out.resize(3); |
| 137 |
|
| 138 |
int subElement; |
| 139 |
typename Traits::DomainType local; |
| 140 |
this->getSubElement(in, subElement, local); |
| 141 |
|
| 142 |
switch (subElement) { |
| 143 |
case 0: |
| 144 |
out[0] = -2; |
| 145 |
out[1] = 2; |
| 146 |
out[2] = 0; |
| 147 |
break; |
| 148 |
case 1: |
| 149 |
out[0] = 0; |
| 150 |
out[1] = -2; |
| 151 |
out[2] = 2; |
| 152 |
break; |
| 153 |
} |
| 154 |
} else { |
| 155 |
out.resize(3); |
| 156 |
out[0] = out[1] = out[2] = 0; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
/** \brief Polynomial order of the shape functions |
| 161 |
Doesn't really apply: these shape functions are only piecewise linear |
| 162 |
*/ |
| 163 |
static constexpr unsigned int order () |
| 164 |
{ |
| 165 |
return 1; |
| 166 |
} |
| 167 |
|
| 168 |
}; |
| 169 |
|
| 170 |
/** |
| 171 |
\brief Uniformly refined linear Lagrange shape functions on the triangle. |
| 172 |
|
| 173 |
This shape function set mimics the P1 shape functions that you would get on |
| 174 |
a uniformly refined grid. Hence these shape functions are only piecewise |
| 175 |
linear! The data layout is identical to P2 shape functions. |
| 176 |
|
| 177 |
Shape functions like these are necessary for hierarchical error estimators |
| 178 |
for certain nonlinear problems. |
| 179 |
|
| 180 |
The functions are associated to points by: |
| 181 |
|
| 182 |
f_0 ~ (0.0, 0.0) |
| 183 |
f_1 ~ (0.5, 0.0) |
| 184 |
f_2 ~ (1.0, 0.0) |
| 185 |
f_3 ~ (0.0, 0.5) |
| 186 |
f_4 ~ (0.5, 0.5) |
| 187 |
f_5 ~ (0.0, 1.0) |
| 188 |
|
| 189 |
\tparam D Type to represent the field in the domain. |
| 190 |
\tparam R Type to represent the field in the range. |
| 191 |
|
| 192 |
\nosubgrouping |
| 193 |
* \ingroup LocalFunctionsImpl |
| 194 |
*/ |
| 195 |
template<class D, class R> |
| 196 |
class RefinedP1LocalBasis<D,R,2> |
| 197 |
: public RefinedSimplexLocalBasis<D,2> |
| 198 |
{ |
| 199 |
public: |
| 200 |
//! \brief export type traits for function signature |
| 201 |
typedef LocalBasisTraits<D,2,Dune::FieldVector<D,2>,R,1,Dune::FieldVector<R,1>, |
| 202 |
Dune::FieldMatrix<R,1,2> > Traits; |
| 203 |
|
| 204 |
//! \brief number of shape functions |
| 205 |
static constexpr unsigned int size () |
| 206 |
{ |
| 207 |
return 6; |
| 208 |
} |
| 209 |
|
| 210 |
//! \brief Evaluate all shape functions |
| 211 |
inline void evaluateFunction (const typename Traits::DomainType& in, |
| 212 |
std::vector<typename Traits::RangeType>& out) const |
| 213 |
{ |
| 214 |
out.resize(6); |
| 215 |
|
| 216 |
int subElement; |
| 217 |
typename Traits::DomainType local; |
| 218 |
this->getSubElement(in, subElement, local); |
| 219 |
|
| 220 |
switch (subElement) { |
| 221 |
case 0 : |
| 222 |
|
| 223 |
out[0] = 1 - local[0] - local[1]; |
| 224 |
out[1] = local[0]; |
| 225 |
out[2] = 0; |
| 226 |
out[3] = local[1]; |
| 227 |
out[4] = 0; |
| 228 |
out[5] = 0; |
| 229 |
break; |
| 230 |
|
| 231 |
case 1 : |
| 232 |
|
| 233 |
out[0] = 0; |
| 234 |
out[1] = 1 - local[0] - local[1]; |
| 235 |
out[2] = local[0]; |
| 236 |
out[3] = 0; |
| 237 |
out[4] = local[1]; |
| 238 |
out[5] = 0; |
| 239 |
break; |
| 240 |
|
| 241 |
case 2 : |
| 242 |
|
| 243 |
out[0] = 0; |
| 244 |
out[1] = 0; |
| 245 |
out[2] = 0; |
| 246 |
out[3] = 1 - local[0] - local[1]; |
| 247 |
out[4] = local[0]; |
| 248 |
out[5] = local[1]; |
| 249 |
break; |
| 250 |
case 3 : |
| 251 |
|
| 252 |
out[0] = 0; |
| 253 |
out[1] = local[1]; |
| 254 |
out[2] = 0; |
| 255 |
out[3] = local[0]; |
| 256 |
out[4] = 1 - local[0] - local[1]; |
| 257 |
out[5] = 0; |
| 258 |
} |
| 259 |
|
| 260 |
} |
| 261 |
|
| 262 |
//! \brief Evaluate Jacobian of all shape functions |
| 263 |
inline void |
| 264 |
evaluateJacobian (const typename Traits::DomainType& in, // position |
| 265 |
std::vector<typename Traits::JacobianType>& out) const // return value |
| 266 |
{ |
| 267 |
out.resize(6); |
| 268 |
|
| 269 |
int subElement; |
| 270 |
typename Traits::DomainType local; |
| 271 |
this->getSubElement(in, subElement, local); |
| 272 |
|
| 273 |
switch (subElement) { |
| 274 |
case 0 : |
| 275 |
|
| 276 |
out[0][0][0] = -2; out[0][0][1] = -2; |
| 277 |
out[1][0][0] = 2; out[1][0][1] = 0; |
| 278 |
out[2][0][0] = 0; out[2][0][1] = 0; |
| 279 |
out[3][0][0] = 0; out[3][0][1] = 2; |
| 280 |
out[4][0][0] = 0; out[4][0][1] = 0; |
| 281 |
out[5][0][0] = 0; out[5][0][1] = 0; |
| 282 |
break; |
| 283 |
|
| 284 |
case 1 : |
| 285 |
|
| 286 |
out[0][0][0] = 0; out[0][0][1] = 0; |
| 287 |
out[1][0][0] = -2; out[1][0][1] = -2; |
| 288 |
out[2][0][0] = 2; out[2][0][1] = 0; |
| 289 |
out[3][0][0] = 0; out[3][0][1] = 0; |
| 290 |
out[4][0][0] = 0; out[4][0][1] = 2; |
| 291 |
out[5][0][0] = 0; out[5][0][1] = 0; |
| 292 |
break; |
| 293 |
|
| 294 |
case 2 : |
| 295 |
|
| 296 |
out[0][0][0] = 0; out[0][0][1] = 0; |
| 297 |
out[1][0][0] = 0; out[1][0][1] = 0; |
| 298 |
out[2][0][0] = 0; out[2][0][1] = 0; |
| 299 |
out[3][0][0] = -2; out[3][0][1] = -2; |
| 300 |
out[4][0][0] = 2; out[4][0][1] = 0; |
| 301 |
out[5][0][0] = 0; out[5][0][1] = 2; |
| 302 |
break; |
| 303 |
case 3 : |
| 304 |
|
| 305 |
out[0][0][0] = 0; out[0][0][1] = 0; |
| 306 |
out[1][0][0] = 0; out[1][0][1] = -2; |
| 307 |
out[2][0][0] = 0; out[2][0][1] = 0; |
| 308 |
out[3][0][0] = -2; out[3][0][1] = 0; |
| 309 |
out[4][0][0] = 2; out[4][0][1] = 2; |
| 310 |
out[5][0][0] = 0; out[5][0][1] = 0; |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
//! \brief Evaluate partial derivatives of all shape functions |
| 315 |
void partial (const std::array<unsigned int, 2>& order, |
| 316 |
const typename Traits::DomainType& in, // position |
| 317 |
std::vector<typename Traits::RangeType>& out) const // return value |
| 318 |
{ |
| 319 |
auto totalOrder = std::accumulate(order.begin(), order.end(), 0); |
| 320 |
if (totalOrder == 0) { |
| 321 |
evaluateFunction(in, out); |
| 322 |
} else if (totalOrder == 1) { |
| 323 |
int subElement; |
| 324 |
typename Traits::DomainType local; |
| 325 |
this->getSubElement(in, subElement, local); |
| 326 |
|
| 327 |
auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1)); |
| 328 |
out.resize(size()); |
| 329 |
|
| 330 |
for (std::size_t i = 0; i < size(); ++i) |
| 331 |
out[i] = 0; |
| 332 |
|
| 333 |
switch (direction) { |
| 334 |
case 0: // direction == 0 |
| 335 |
|
| 336 |
switch (subElement) { |
| 337 |
case 0 : |
| 338 |
out[0] = -2; |
| 339 |
out[1] = 2; |
| 340 |
break; |
| 341 |
case 1 : |
| 342 |
out[1] = -2; |
| 343 |
out[2] = 2; |
| 344 |
break; |
| 345 |
case 2 : |
| 346 |
out[3] = -2; |
| 347 |
out[4] = 2; |
| 348 |
break; |
| 349 |
case 3 : |
| 350 |
out[3] = -2; |
| 351 |
out[4] = 2; |
| 352 |
} |
| 353 |
break; |
| 354 |
|
| 355 |
case 1: // direction == 1 |
| 356 |
|
| 357 |
switch (subElement) { |
| 358 |
case 0 : |
| 359 |
out[0] = -2; |
| 360 |
out[3] = 2; |
| 361 |
break; |
| 362 |
case 1 : |
| 363 |
out[1] = -2; |
| 364 |
out[4] = 2; |
| 365 |
break; |
| 366 |
case 2 : |
| 367 |
out[3] = -2; |
| 368 |
out[5] = 2; |
| 369 |
break; |
| 370 |
case 3 : |
| 371 |
out[1] = -2; |
| 372 |
out[4] = 2; |
| 373 |
} |
| 374 |
break; |
| 375 |
|
| 376 |
default: |
| 377 |
DUNE_THROW(RangeError, "Component out of range."); |
| 378 |
} |
| 379 |
} else { |
| 380 |
out.resize(size()); |
| 381 |
for (std::size_t i = 0; i < size(); ++i) |
| 382 |
out[i] = 0; |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
/** \brief Polynomial order of the shape functions |
| 387 |
Doesn't really apply: these shape functions are only piecewise linear |
| 388 |
*/ |
| 389 |
static constexpr unsigned int order () |
| 390 |
{ |
| 391 |
return 1; |
| 392 |
} |
| 393 |
|
| 394 |
}; |
| 395 |
|
| 396 |
/** |
| 397 |
\brief Uniformly refined linear Lagrange shape functions on the 3D-simplex (tetrahedron). |
| 398 |
|
| 399 |
This shape function set mimics the P1 shape functions that you would get on |
| 400 |
a uniformly refined grid. Hence these shape functions are only piecewise |
| 401 |
linear! The data layout is identical to P2 shape functions. |
| 402 |
|
| 403 |
Shape functions like these are necessary for hierarchical error estimators |
| 404 |
for certain nonlinear problems. |
| 405 |
|
| 406 |
The functions are associated to points by: |
| 407 |
|
| 408 |
f_0 ~ (0.0, 0.0, 0.0) |
| 409 |
f_1 ~ (1.0, 0.0, 0.0) |
| 410 |
f_2 ~ (0.0, 1.0, 0.0) |
| 411 |
f_3 ~ (0.0, 0.0, 1.0) |
| 412 |
f_4 ~ (0.5, 0.0, 0.0) |
| 413 |
f_5 ~ (0.5, 0.5, 0.0) |
| 414 |
f_6 ~ (0.0, 0.5, 0.0) |
| 415 |
f_7 ~ (0.0, 0.0, 0.5) |
| 416 |
f_8 ~ (0.5, 0.0, 0.5) |
| 417 |
f_9 ~ (0.0, 0.5, 0.5) |
| 418 |
|
| 419 |
\tparam D Type to represent the field in the domain. |
| 420 |
\tparam R Type to represent the field in the range. |
| 421 |
|
| 422 |
\nosubgrouping |
| 423 |
* \ingroup LocalFunctionsImpl |
| 424 |
*/ |
| 425 |
template<class D, class R> |
| 426 |
class RefinedP1LocalBasis<D,R,3> |
| 427 |
: public RefinedSimplexLocalBasis<D,3> |
| 428 |
{ |
| 429 |
public: |
| 430 |
//! \brief export type traits for function signature |
| 431 |
typedef LocalBasisTraits<D,3,Dune::FieldVector<D,3>,R,1,Dune::FieldVector<R,1>, |
| 432 |
Dune::FieldMatrix<R,1,3> > Traits; |
| 433 |
|
| 434 |
//! \brief number of shape functions |
| 435 |
static constexpr unsigned int size () |
| 436 |
{ |
| 437 |
return 10; |
| 438 |
} |
| 439 |
|
| 440 |
//! \brief Evaluate all shape functions |
| 441 |
inline void evaluateFunction (const typename Traits::DomainType& in, |
| 442 |
std::vector<typename Traits::RangeType>& out) const |
| 443 |
{ |
| 444 |
out.resize(10); |
| 445 |
|
| 446 |
int subElement; |
| 447 |
typename Traits::DomainType local; |
| 448 |
this->getSubElement(in, subElement, local); |
| 449 |
|
| 450 |
switch (subElement) { |
| 451 |
case 0 : |
| 452 |
|
| 453 |
out[0] = 1 - local[0] - local[1] - local[2]; |
| 454 |
out[1] = local[0]; |
| 455 |
out[2] = 0; |
| 456 |
out[3] = local[1]; |
| 457 |
out[4] = 0; |
| 458 |
out[5] = 0; |
| 459 |
out[6] = local[2]; |
| 460 |
out[7] = 0; |
| 461 |
out[8] = 0; |
| 462 |
out[9] = 0; |
| 463 |
break; |
| 464 |
|
| 465 |
case 1 : |
| 466 |
|
| 467 |
out[0] = 0; |
| 468 |
out[1] = 1 - local[0] - local[1] -local[2]; |
| 469 |
out[2] = local[0]; |
| 470 |
out[3] = 0; |
| 471 |
out[4] = local[1]; |
| 472 |
out[5] = 0; |
| 473 |
out[6] = 0; |
| 474 |
out[7] = local[2]; |
| 475 |
out[8] = 0; |
| 476 |
out[9] = 0; |
| 477 |
break; |
| 478 |
|
| 479 |
case 2 : |
| 480 |
|
| 481 |
out[0] = 0; |
| 482 |
out[1] = 0; |
| 483 |
out[2] = 0; |
| 484 |
out[3] = 1 - local[0] - local[1] -local[2]; |
| 485 |
out[4] = local[0]; |
| 486 |
out[5] = local[1]; |
| 487 |
out[6] = 0; |
| 488 |
out[7] = 0; |
| 489 |
out[8] = local[2]; |
| 490 |
out[9] = 0; |
| 491 |
break; |
| 492 |
|
| 493 |
case 3 : |
| 494 |
|
| 495 |
out[0] = 0; |
| 496 |
out[1] = 0; |
| 497 |
out[2] = 0; |
| 498 |
out[3] = 0; |
| 499 |
out[4] = 0; |
| 500 |
out[5] = 0; |
| 501 |
out[6] = 1 - local[0] - local[1] -local[2]; |
| 502 |
out[7] = local[0]; |
| 503 |
out[8] = local[1]; |
| 504 |
out[9] = local[2]; |
| 505 |
break; |
| 506 |
|
| 507 |
case 4 : |
| 508 |
|
| 509 |
out[0] = 0; |
| 510 |
out[1] = 1 - local[0] - local[1] -local[2]; |
| 511 |
out[2] = 0; |
| 512 |
out[3] = local[0]; |
| 513 |
out[4] = 0; |
| 514 |
out[5] = 0; |
| 515 |
out[6] = local[1]; |
| 516 |
out[7] = local[2]; |
| 517 |
out[8] = 0; |
| 518 |
out[9] = 0; |
| 519 |
break; |
| 520 |
|
| 521 |
case 5 : |
| 522 |
|
| 523 |
out[0] = 0; |
| 524 |
out[1] = local[1]; |
| 525 |
out[2] = 0; |
| 526 |
out[3] = local[0]; |
| 527 |
out[4] = 1 - local[0] - local[1] -local[2]; |
| 528 |
out[5] = 0; |
| 529 |
out[6] = 0; |
| 530 |
out[7] = local[2]; |
| 531 |
out[8] = 0; |
| 532 |
out[9] = 0; |
| 533 |
break; |
| 534 |
|
| 535 |
case 6 : |
| 536 |
|
| 537 |
out[0] = 0; |
| 538 |
out[1] = 0; |
| 539 |
out[2] = 0; |
| 540 |
out[3] = 1 - local[0] - local[1] -local[2]; |
| 541 |
out[4] = 0; |
| 542 |
out[5] = 0; |
| 543 |
out[6] = local[0]; |
| 544 |
out[7] = local[1]; |
| 545 |
out[8] = local[2]; |
| 546 |
out[9] = 0; |
| 547 |
break; |
| 548 |
|
| 549 |
case 7 : |
| 550 |
|
| 551 |
out[0] = 0; |
| 552 |
out[1] = 0; |
| 553 |
out[2] = 0; |
| 554 |
out[3] = 1 - local[0] - local[1] -local[2]; |
| 555 |
out[4] = local[2]; |
| 556 |
out[5] = 0; |
| 557 |
out[6] = 0; |
| 558 |
out[7] = local[1]; |
| 559 |
out[8] = local[0]; |
| 560 |
out[9] = 0; |
| 561 |
break; |
| 562 |
} |
| 563 |
|
| 564 |
} |
| 565 |
|
| 566 |
//! \brief Evaluate Jacobian of all shape functions |
| 567 |
inline void |
| 568 |
evaluateJacobian (const typename Traits::DomainType& in, // position |
| 569 |
std::vector<typename Traits::JacobianType>& out) const // return value |
| 570 |
{ |
| 571 |
out.resize(10); |
| 572 |
|
| 573 |
int subElement; |
| 574 |
typename Traits::DomainType local; |
| 575 |
this->getSubElement(in, subElement, local); |
| 576 |
|
| 577 |
switch (subElement) { |
| 578 |
case 0 : |
| 579 |
|
| 580 |
out[0][0][0] = -2; out[0][0][1] = -2; out[0][0][2] = -2; |
| 581 |
out[1][0][0] = 2; out[1][0][1] = 0; out[1][0][2] = 0; |
| 582 |
out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0; |
| 583 |
out[3][0][0] = 0; out[3][0][1] = 2; out[3][0][2] = 0; |
| 584 |
out[4][0][0] = 0; out[4][0][1] = 0; out[4][0][2] = 0; |
| 585 |
out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0; |
| 586 |
out[6][0][0] = 0; out[6][0][1] = 0; out[6][0][2] = 2; |
| 587 |
out[7][0][0] = 0; out[7][0][1] = 0; out[7][0][2] = 0; |
| 588 |
out[8][0][0] = 0; out[8][0][1] = 0; out[8][0][2] = 0; |
| 589 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 0; |
| 590 |
break; |
| 591 |
|
| 592 |
case 1 : |
| 593 |
|
| 594 |
out[0][0][0] = 0; out[0][0][1] = 0; out[0][0][2] = 0; |
| 595 |
out[1][0][0] = -2; out[1][0][1] = -2; out[1][0][2] = -2; |
| 596 |
out[2][0][0] = 2; out[2][0][1] = 0; out[2][0][2] = 0; |
| 597 |
out[3][0][0] = 0; out[3][0][1] = 0; out[3][0][2] = 0; |
| 598 |
out[4][0][0] = 0; out[4][0][1] = 2; out[4][0][2] = 0; |
| 599 |
out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0; |
| 600 |
out[6][0][0] = 0; out[6][0][1] = 0; out[6][0][2] = 0; |
| 601 |
out[7][0][0] = 0; out[7][0][1] = 0; out[7][0][2] = 2; |
| 602 |
out[8][0][0] = 0; out[8][0][1] = 0; out[8][0][2] = 0; |
| 603 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 0; |
| 604 |
break; |
| 605 |
|
| 606 |
case 2 : |
| 607 |
|
| 608 |
out[0][0][0] = 0; out[0][0][1] = 0; out[0][0][2] = 0; |
| 609 |
out[1][0][0] = 0; out[1][0][1] = 0; out[1][0][2] = 0; |
| 610 |
out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0; |
| 611 |
out[3][0][0] = -2; out[3][0][1] = -2; out[3][0][2] = -2; |
| 612 |
out[4][0][0] = 2; out[4][0][1] = 0; out[4][0][2] = 0; |
| 613 |
out[5][0][0] = 0; out[5][0][1] = 2; out[5][0][2] = 0; |
| 614 |
out[6][0][0] = 0; out[6][0][1] = 0; out[6][0][2] = 0; |
| 615 |
out[7][0][0] = 0; out[7][0][1] = 0; out[7][0][2] = 0; |
| 616 |
out[8][0][0] = 0; out[8][0][1] = 0; out[8][0][2] = 2; |
| 617 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 0; |
| 618 |
break; |
| 619 |
|
| 620 |
case 3 : |
| 621 |
|
| 622 |
out[0][0][0] = 0; out[0][0][1] = 0; out[0][0][2] = 0; |
| 623 |
out[1][0][0] = 0; out[1][0][1] = 0; out[1][0][2] = 0; |
| 624 |
out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0; |
| 625 |
out[3][0][0] = 0; out[3][0][1] = 0; out[3][0][2] = 0; |
| 626 |
out[4][0][0] = 0; out[4][0][1] = 0; out[4][0][2] = 0; |
| 627 |
out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0; |
| 628 |
out[6][0][0] = -2; out[6][0][1] = -2; out[6][0][2] = -2; |
| 629 |
out[7][0][0] = 2; out[7][0][1] = 0; out[7][0][2] = 0; |
| 630 |
out[8][0][0] = 0; out[8][0][1] = 2; out[8][0][2] = 0; |
| 631 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 2; |
| 632 |
break; |
| 633 |
|
| 634 |
case 4 : |
| 635 |
|
| 636 |
out[0][0][0] = 0; out[0][0][1] = 0; out[0][0][2] = 0; |
| 637 |
out[1][0][0] = 0; out[1][0][1] = -2; out[1][0][2] = -2; |
| 638 |
out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0; |
| 639 |
out[3][0][0] = 0; out[3][0][1] = 2; out[3][0][2] = 0; |
| 640 |
out[4][0][0] = 0; out[4][0][1] = 0; out[4][0][2] = 0; |
| 641 |
out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0; |
| 642 |
out[6][0][0] = -2; out[6][0][1] = -2; out[6][0][2] = 0; |
| 643 |
out[7][0][0] = 2; out[7][0][1] = 2; out[7][0][2] = 2; |
| 644 |
out[8][0][0] = 0; out[8][0][1] = 0; out[8][0][2] = 0; |
| 645 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 0; |
| 646 |
break; |
| 647 |
|
| 648 |
case 5 : |
| 649 |
|
| 650 |
out[0][0][0] = 0; out[0][0][1] = 0; out[0][0][2] = 0; |
| 651 |
out[1][0][0] = 0; out[1][0][1] = -2; out[1][0][2] = -2; |
| 652 |
out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0; |
| 653 |
out[3][0][0] = -2; out[3][0][1] = 0; out[3][0][2] = 0; |
| 654 |
out[4][0][0] = 2; out[4][0][1] = 2; out[4][0][2] = 0; |
| 655 |
out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0; |
| 656 |
out[6][0][0] = 0; out[6][0][1] = 0; out[6][0][2] = 0; |
| 657 |
out[7][0][0] = 0; out[7][0][1] = 0; out[7][0][2] = 2; |
| 658 |
out[8][0][0] = 0; out[8][0][1] = 0; out[8][0][2] = 0; |
| 659 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 0; |
| 660 |
break; |
| 661 |
|
| 662 |
case 6 : |
| 663 |
|
| 664 |
out[0][0][0] = 0; out[0][0][1] = 0; out[0][0][2] = 0; |
| 665 |
out[1][0][0] = 0; out[1][0][1] = 0; out[1][0][2] = 0; |
| 666 |
out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0; |
| 667 |
out[3][0][0] = 0; out[3][0][1] = 0; out[3][0][2] = -2; |
| 668 |
out[4][0][0] = 0; out[4][0][1] = 0; out[4][0][2] = 0; |
| 669 |
out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0; |
| 670 |
out[6][0][0] = -2; out[6][0][1] = -2; out[6][0][2] = 0; |
| 671 |
out[7][0][0] = 2; out[7][0][1] = 0; out[7][0][2] = 0; |
| 672 |
out[8][0][0] = 0; out[8][0][1] = 2; out[8][0][2] = 2; |
| 673 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 0; |
| 674 |
break; |
| 675 |
|
| 676 |
case 7 : |
| 677 |
|
| 678 |
out[0][0][0] = 0; out[0][0][1] = 0; out[0][0][2] = 0; |
| 679 |
out[1][0][0] = 0; out[1][0][1] = 0; out[1][0][2] = 0; |
| 680 |
out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0; |
| 681 |
out[3][0][0] = -2; out[3][0][1] = -2; out[3][0][2] = -2; |
| 682 |
out[4][0][0] = 2; out[4][0][1] = 2; out[4][0][2] = 0; |
| 683 |
out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0; |
| 684 |
out[6][0][0] = 0; out[6][0][1] = 0; out[6][0][2] = 0; |
| 685 |
out[7][0][0] = 0; out[7][0][1] = -2; out[7][0][2] = 0; |
| 686 |
out[8][0][0] = 0; out[8][0][1] = 2; out[8][0][2] = 2; |
| 687 |
out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 0; |
| 688 |
break; |
| 689 |
} |
| 690 |
} |
| 691 |
|
| 692 |
//! \brief Evaluate partial derivatives of all shape functions |
| 693 |
void partial (const std::array<unsigned int, 3>& order, |
| 694 |
const typename Traits::DomainType& in, // position |
| 695 |
std::vector<typename Traits::RangeType>& out) const // return value |
| 696 |
{ |
| 697 |
auto totalOrder = std::accumulate(order.begin(), order.end(), 0); |
| 698 |
if (totalOrder == 0) { |
| 699 |
evaluateFunction(in, out); |
| 700 |
} else if (totalOrder == 1) { |
| 701 |
int subElement; |
| 702 |
typename Traits::DomainType local; |
| 703 |
this->getSubElement(in, subElement, local); |
| 704 |
|
| 705 |
auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1)); |
| 706 |
out.resize(size()); |
| 707 |
|
| 708 |
for (std::size_t i = 0; i < size(); ++i) |
| 709 |
out[i] = 0; |
| 710 |
|
| 711 |
switch (direction) { |
| 712 |
case 0: // direction == 0 |
| 713 |
|
| 714 |
switch (subElement) { |
| 715 |
case 0 : |
| 716 |
out[0] = -2; |
| 717 |
out[1] = 2; |
| 718 |
break; |
| 719 |
case 1 : |
| 720 |
out[1] = -2; |
| 721 |
out[2] = 2; |
| 722 |
break; |
| 723 |
case 2 : |
| 724 |
out[3] = -2; |
| 725 |
out[4] = 2; |
| 726 |
break; |
| 727 |
case 3 : |
| 728 |
out[6] = -2; |
| 729 |
out[7] = 2; |
| 730 |
break; |
| 731 |
case 4 : |
| 732 |
out[6] = -2; |
| 733 |
out[7] = 2; |
| 734 |
break; |
| 735 |
case 5 : |
| 736 |
out[3] = -2; |
| 737 |
out[4] = 2; |
| 738 |
break; |
| 739 |
case 6 : |
| 740 |
out[6] = -2; |
| 741 |
out[7] = 2; |
| 742 |
break; |
| 743 |
case 7 : |
| 744 |
out[3] = -2; |
| 745 |
out[4] = 2; |
| 746 |
break; |
| 747 |
} |
| 748 |
break; |
| 749 |
|
| 750 |
case 1: // direction == 1 |
| 751 |
|
| 752 |
switch (subElement) { |
| 753 |
case 0 : |
| 754 |
out[0] = -2; |
| 755 |
out[3] = 2; |
| 756 |
break; |
| 757 |
case 1 : |
| 758 |
out[1] = -2; |
| 759 |
out[4] = 2; |
| 760 |
break; |
| 761 |
case 2 : |
| 762 |
out[3] = -2; |
| 763 |
out[5] = 2; |
| 764 |
break; |
| 765 |
case 3 : |
| 766 |
out[6] = -2; |
| 767 |
out[8] = 2; |
| 768 |
break; |
| 769 |
case 4 : |
| 770 |
out[1] = -2; |
| 771 |
out[3] = 2; |
| 772 |
out[6] = -2; |
| 773 |
break; |
| 774 |
case 5 : |
| 775 |
out[1] = -2; |
| 776 |
out[4] = 2; |
| 777 |
break; |
| 778 |
case 6 : |
| 779 |
out[6] = -2; |
| 780 |
out[8] = 2; |
| 781 |
break; |
| 782 |
case 7 : |
| 783 |
out[3] = -2; |
| 784 |
out[4] = 2; |
| 785 |
out[7] = -2; |
| 786 |
out[8] = 2; |
| 787 |
break; |
| 788 |
} |
| 789 |
break; |
| 790 |
|
| 791 |
case 2: // direction == 2 |
| 792 |
|
| 793 |
switch (subElement) { |
| 794 |
case 0 : |
| 795 |
out[0] = -2; |
| 796 |
out[6] = 2; |
| 797 |
break; |
| 798 |
case 1 : |
| 799 |
out[1] = -2; |
| 800 |
out[7] = 2; |
| 801 |
break; |
| 802 |
case 2 : |
| 803 |
out[3] = -2; |
| 804 |
out[8] = 2; |
| 805 |
break; |
| 806 |
case 3 : |
| 807 |
out[6] = -2; |
| 808 |
out[9] = 2; |
| 809 |
break; |
| 810 |
case 4 : |
| 811 |
out[1] = -2; |
| 812 |
out[7] = 2; |
| 813 |
break; |
| 814 |
case 5 : |
| 815 |
out[1] = -2; |
| 816 |
out[7] = 2; |
| 817 |
break; |
| 818 |
case 6 : |
| 819 |
out[3] = -2; |
| 820 |
out[8] = 2; |
| 821 |
break; |
| 822 |
case 7 : |
| 823 |
out[3] = -2; |
| 824 |
out[8] = 2; |
| 825 |
break; |
| 826 |
} |
| 827 |
break; |
| 828 |
|
| 829 |
default: |
| 830 |
DUNE_THROW(RangeError, "Component out of range."); |
| 831 |
} |
| 832 |
} else { |
| 833 |
out.resize(size()); |
| 834 |
for (std::size_t i = 0; i < size(); ++i) |
| 835 |
out[i] = 0; |
| 836 |
} |
| 837 |
} |
| 838 |
|
| 839 |
/** \brief Polynomial order of the shape functions |
| 840 |
* Doesn't really apply: these shape functions are only piecewise linear |
| 841 |
*/ |
| 842 |
static constexpr unsigned int order () |
| 843 |
{ |
| 844 |
return 1; |
| 845 |
} |
| 846 |
|
| 847 |
}; |
| 848 |
} |
| 849 |
#endif |