Dear all,
the question is simple: how can I create a hinged BC in C++? I would like to create a simple beam with two boundary conditions: one fixed, one hinged. As far as I understand, for the hinged BC I need to apply a DirichletBC
to a point, but the problem is that Fenics dies.
You can see the scheme in the image here: http://imgur.com/KV02yen
This is my code, it works with two fixed ends, however, with one hinged, I get the error below.
I am surely missing something, can anyone help me?
Thanks!
CODE
class nodalForce2D : public Expression
{
public:
nodalForce2D(Point p, double valuex, double valuey) : Expression(2), p_(p), vx_(valuex), vy_(valuey) { }
void eval(Array<double>& values, const Array<double>& x) const
{
if (p_.distance(Point(x[0], x[1])) < GEOMETRIC_TOL)
{
values[0] = vx_;
values[1] = vy_;
}
}
private:
double vx_, vy_;
Point p_;
};
// Dirichelet BCs
DirichletBC bcFixed(*V, clamped, fixed, "pointwise");
DirichletBC bcHinge(*((*V)[1]), Constant(0.0), hinge, "pointwise");
DirichletBC bcAnother(*V, clamped, fixedPoint, "pointwise");
std::vector<const DirichletBC*> bcs { &bcFixed, &bcHinge };
//std::vector<const DirichletBC*> bcs { &bcFixed, &bcAnother };
ERROR
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to evaluate expression.
*** Reason: Missing eval() function (must be overloaded).
*** Where: This error was encountered inside Expression.cpp.
*** Process: unknown
***
*** DOLFIN version: 1.5.0
*** Git changeset: f467b66dcfd821ec20e9f9070c7cef5a991dbc42
*** -------------------------------------------------------------------------
[Senseis-MacBook-Pro:11236] *** Process received signal ***
[Senseis-MacBook-Pro:11236] Signal: Abort trap: 6 (6)
[Senseis-MacBook-Pro:11236] Signal code: (0)
[Senseis-MacBook-Pro:11236] [ 0] 2 libsystem_platform.dylib 0x00007fff93cd3eaa _sigtramp + 26
[Senseis-MacBook-Pro:11236] [ 1] 3 ??? 0x0000000000000002 0x0 + 2
[Senseis-MacBook-Pro:11236] [ 2] 4 libsystem_c.dylib 0x00007fff9bfc96e7 abort + 129
[Senseis-MacBook-Pro:11236] [ 3] 5 libc++abi.dylib 0x00007fff8eb38f81 __cxa_bad_cast + 0
[Senseis-MacBook-Pro:11236] [ 4] 6 libc++abi.dylib 0x00007fff8eb5ea2f _ZL25default_terminate_handlerv + 243
[Senseis-MacBook-Pro:11236] [ 5] 7 libobjc.A.dylib 0x00007fff8b1094a6 _ZL15_objc_terminatev + 124
[Senseis-MacBook-Pro:11236] [ 6] 8 libc++abi.dylib 0x00007fff8eb5c19e _ZSt11__terminatePFvvE + 8
[Senseis-MacBook-Pro:11236] [ 7] 9 libc++abi.dylib 0x00007fff8eb5bc12 _ZN10__cxxabiv1L22exception_cleanup_funcE19_Unwind_Reason_CodeP17_Unwind_Exception + 0
[Senseis-MacBook-Pro:11236] [ 8] 10 libdolfin.1.5.dylib 0x000000010fb6f69f _ZNK6dolfin6Logger12dolfin_errorENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES7_S7_i + 4575
[Senseis-MacBook-Pro:11236] [ 9] 11 libdolfin.1.5.dylib 0x000000010fb6c5fa _ZN6dolfin12dolfin_errorENSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEES6_S6_z + 394
[Senseis-MacBook-Pro:11236] [10] 12 libdolfin.1.5.dylib 0x000000010fa26d7b _ZNK6dolfin10Expression4evalERNS_5ArrayIdEERKS2_ + 91
[Senseis-MacBook-Pro:11236] [11] 13 libdolfin.1.5.dylib 0x000000010fa3453b _ZNK6dolfin15GenericFunction8evaluateEPdPKdRKN3ufc4cellE + 155
[Senseis-MacBook-Pro:11236] [12] 14 demo_hyperelasticity 0x000000010f949f06 _ZNK32hyperelasticity_finite_element_113evaluate_dofsEPdRKN3ufc8functionEPKdiRKNS1_4cellE + 86
[Senseis-MacBook-Pro:11236] [13] 15 libdolfin.1.5.dylib 0x000000010f9e3d0b _ZNK6dolfin11DirichletBC20compute_bc_pointwiseERNSt3__113unordered_mapImdNS1_4hashImEENS1_8equal_toImEENS1_9allocatorINS1_4pairIKmdEEEEEERNS0_9LocalDataE + 2411
[Senseis-MacBook-Pro:11236] [14] 16 libdolfin.1.5.dylib 0x000000010f9dff44 _ZNK6dolfin11DirichletBC10compute_bcERNSt3__113unordered_mapImdNS1_4hashImEENS1_8equal_toImEENS1_9allocatorINS1_4pairIKmdEEEEEERNS0_9LocalDataENS1_12basic_stringIcNS1_11char_traitsIcEENS7_IcEEEE + 356
[Senseis-MacBook-Pro:11236] [15] 17 libdolfin.1.5.dylib 0x000000010f9dfc94 _ZNK6dolfin11DirichletBC19get_boundary_valuesERNSt3__113unordered_mapImdNS1_4hashImEENS1_8equal_toImEENS1_9allocatorINS1_4pairIKmdEEEEEENS1_12basic_stringIcNS1_11char_traitsIcEENS7_IcEEEE + 84
[Senseis-MacBook-Pro:11236] [16] 18 libdolfin.1.5.dylib 0x000000010fa1bc0a _ZN6dolfin15SystemAssembler8assembleEPNS_13GenericMatrixEPNS_13GenericVectorEPKS3_ + 1194
[Senseis-MacBook-Pro:11236] [17] 19 libdolfin.1.5.dylib 0x000000010f9d43e9 _ZN6dolfin15assemble_systemERNS_13GenericMatrixERNS_13GenericVectorERKNS_4FormES6_NSt3__16vectorIPKNS_11DirichletBCENS7_9allocatorISB_EEEE + 121
[Senseis-MacBook-Pro:11236] [18] 20 demo_hyperelasticity 0x000000010f941791 main + 2305
[Senseis-MacBook-Pro:11236] [19] 21 libdyld.dylib 0x00007fff8d33f5ad start + 1
[Senseis-MacBook-Pro:11236] *** End of error message ***
Abort trap: 6