User operator and finite element do not work together

19 views
Skip to first unread message
Assigned to lik...@wp.pl by me

Karol Lewandowski

unread,
Oct 13, 2021, 7:36:18 PM10/13/21
to MoFEM Q&A
I have a silly mistake, where I am pushing an Operator to the wrong Pipeline. 
Is there any way to track this type of bug in MoFEM?


If not, maybe we should think about implementing it. 

Currently, it seems very hard to figure which operator or which pipeline is causing issues. 
(when solving nonlinear problems)

Karol Lewandowski

unread,
Oct 13, 2021, 7:53:43 PM10/13/21
to MoFEM Q&A
Ok, actually the error message contains the name of the form Integrator, so it is possible to track it down.

[0] <error> #1 setPtrFE() line 439 in /Users/karollewandowski/mofem_install/mofem-cephas/mofem/src/finite_elements/impl/VolumeElementForcesAndSourcesCore.cpp
Karol-MacBook-Pro-15:users_modules karollewandowski$ 
[0] <error> #2 (Calling user data operator MoFEM::FormsIntegrators<MoFEM::VolumeElementForcesAndSourcesCoreBase::UserDataOperator>::Assembly<(MoFEM::AssemblyType)0>::LinearForm<(MoFEM::IntegrationType)0>::OpSource<1, 3> rowField U colField U) loopOverOperators() line 1292 in /Users/karollewandowski/mofem_install/mofem-cephas/mofem/src/finite_elements/impl/ForcesAndSourcesCore.cpp

Lukasz Kaczmraczyk

unread,
Oct 14, 2021, 5:48:55 AM10/14/21
to MoFEM Q&A

Hi,

I can just to add, this error happens when you use a specific operator, for example for Face, on Volume. Face operator can ask for normal, which makes no sense on Volume.
But yes, we tract operator names thanks to that snipped,

MoFEMErrorCode
VolumeElementForcesAndSourcesCoreBase::UserDataOperator::setPtrFE(
    ForcesAndSourcesCore *ptr) {
  MoFEMFunctionBeginHot;
  if (!(ptrFE = dynamic_cast<VolumeElementForcesAndSourcesCoreBase *>(ptr)))
    SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
            "User operator and finite element do not work together");
  MoFEMFunctionReturnHot(0);
}

which check type op, and the if not throw error as follows,

#define CATCH_OP_ERRORS(OP)                                                    \
  catch (MoFEMExceptionInitial const &ex) {                                    \
    FUNCTION_NAME_WITH_OP_NAME(OP) << PETSC_FUNCTION_NAME;                     \
    return PetscError(PETSC_COMM_SELF, ex.lINE, ss.str().c_str(), __FILE__,    \
                      ex.errorCode, PETSC_ERROR_INITIAL, ex.what());           \
  }                                                                            \
  catch (MoFEMExceptionRepeat const &ex) {                                     \
    FUNCTION_NAME_WITH_OP_NAME(OP) << PETSC_FUNCTION_NAME;                     \
    return PetscError(PETSC_COMM_SELF, ex.lINE, ss.str().c_str(), __FILE__,    \
                      ex.errorCode, PETSC_ERROR_REPEAT, " ");                  \
  }                                                                            \
  catch (MoFEMException const &ex) {                                           \
    FUNCTION_NAME_WITH_OP_NAME(OP) << ex.errorMessage;                         \
    SETERRQ(PETSC_COMM_SELF, ex.errorCode, ss.str().c_str());                  \
  }                                                                            \
  catch (std::exception const &ex) {                                           \
    std::string message("Error: " + std::string(ex.what()) + " at " +          \
                        boost::lexical_cast<std::string>(__LINE__) + " : " +   \
                        std::string(__FILE__) + " in " +                       \
                        std::string(PETSC_FUNCTION_NAME));                     \
    FUNCTION_NAME_WITH_OP_NAME(OP) << message;                                 \
    SETERRQ(PETSC_COMM_SELF, MOFEM_STD_EXCEPTION_THROW, ss.str().c_str());     \
  }

Regards,
L

Reply all
Reply to author
Forward
0 new messages