30 using namespace MoFEM;
32 static char help[] =
"...\n\n";
64 if (
auto e_ptr = field_ents[0]) {
66 entsIndices.push_back(boost::make_shared<MyStorage>(data.
getIndices()));
68 e_ptr->getWeakStoragePtr() = entsIndices.back();
70 MOFEM_LOG(
"SYNC", Sev::inform) <<
"Set " << e_ptr->getEntTypeName() <<
" "
71 << side <<
" : " << entsIndices.size();
76 if (
auto cast_ptr = boost::dynamic_pointer_cast<MyStorage>(ptr))
77 MOFEM_LOG(
"SYNC", Sev::noisy) <<
"Cast works";
83 "Pointer to stored data is expected to be set");
86 if (
auto ptr = e_ptr->getSharedStoragePtr<
MyStorage>()) {
88 << data.
getIndices() <<
" : " << ptr->globalIndices;
91 "Pointer to stored data is expected to be set");
96 "Pointer to entity should be set by finite element");
103 static std::vector<SharedVecInt>
124 if (
auto e_ptr = field_ents[0]) {
127 <<
"Test " << e_ptr->getEntTypeName() <<
" " << side;
131 if (
auto ptr = e_ptr->getSharedStoragePtr<
MyStorage>()) {
134 << data.
getIndices() <<
" : " << ptr->globalIndices;
138 auto diff = data.
getIndices() - ptr->globalIndices;
139 auto dot = inner_prod(diff, diff);
145 "Pointer to stored data is expected to be set");
150 "Pointer to entity should be set by finite element");
159 :
VolOp(field_name, OPROW), V(
v) {}
165 std::vector<double>
v(nb_dofs, 1);
179 int main(
int argc,
char *argv[]) {
195 DMType dm_name =
"DMMOFEM";
215 auto dm = simple_interface->
getDM();
217 auto domain_fe = boost::make_shared<VolEle>(m_field);
219 domain_fe->getRuleHook =
VolRule();
221 auto get_skin = [&]() {
223 CHKERR m_field.
get_moab().get_entities_by_dimension(0, 3, ents,
true);
226 CHKERR skin.find_skin(0, ents,
false, skin_ents);
228 ParallelComm *pcomm =
231 CHKERR pcomm->filter_pstatus(skin_ents,
232 PSTATUS_SHARED | PSTATUS_MULTISHARED,
233 PSTATUS_NOT, -1, &proc_skin);
235 for (
auto d : {0, 1, 2})
237 moab::Interface::UNION);
242 auto get_mark_skin_dofs = [&](Range &&skin) {
244 auto marker_ptr = boost::make_shared<std::vector<unsigned char>>();
252 auto mark_dofs = get_mark_skin_dofs(get_skin());
255 domain_fe->getOpPtrVector().push_back(
new OpVolumeSet(
"FIELD"));
256 domain_fe->getOpPtrVector().push_back(
new OpVolumeTest(
"FIELD"));
258 domain_fe->getOpPtrVector().push_back(
259 new OpSetBc(
"FIELD",
true, mark_dofs));
261 domain_fe->getOpPtrVector().push_back(
new OpUnSetBc(
"FIELD"));
271 CHKERR VecGhostUpdateBegin(
v, ADD_VALUES, SCATTER_REVERSE);
272 CHKERR VecGhostUpdateEnd(
v, ADD_VALUES, SCATTER_REVERSE);
273 CHKERR VecGhostUpdateBegin(
v, INSERT_VALUES, SCATTER_FORWARD);
274 CHKERR VecGhostUpdateEnd(
v, INSERT_VALUES, SCATTER_FORWARD);
277 INSERT_VALUES, SCATTER_REVERSE);
287 auto loc_idx = dof->getPetscLocalDofIdx();
289 if (dof->getFieldData() != array[loc_idx])
291 "Data inconsistency");
293 if ((*mark_dofs)[loc_idx]) {
294 if (array[loc_idx] != 0)
296 "Dof assembled, but it should be not");
298 if (array[loc_idx] == 0)
300 "Dof not assembled, but it should be");
304 CHKERR VecRestoreArray(
v, &array);
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
MoFEM::FaceElementForcesAndSourcesCore FaceEle
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
FaceElementForcesAndSourcesCoreSwitch< 0 > FaceElementForcesAndSourcesCore
Face finite element default.
VolumeElementForcesAndSourcesCoreSwitch< 0 > VolumeElementForcesAndSourcesCore
Volume finite element default.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
double v
phase velocity of light in medium (cm/ns)
const FTensor::Tensor2< T, Dim, Dim > Vec
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasVector< int > VectorInt
implementation of Data Operators for Forces and Sources
DeprecatedCoreInterface Interface
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
const VectorFieldEntities & getFieldEntities() const
get field entities
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Set indices on entities on finite element.
keeps basic data about problem
auto & getNumeredRowDofsPtr() const
get access to numeredRowDofsPtr storing DOFs on rows
Problem manager is used to build and partition problems.
MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc, const enum MarkOP op, const Range ents, std::vector< unsigned char > &marker) const
Create vector with marked indices.
Simple interface for fast problem set-up.
MoFEMErrorCode addDomainField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getDM(DM *dm)
Get DM.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name)
Load mesh file.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
const std::string getProblemName() const
Get the Problem Name.
const std::string getDomainFEName() const
Get the Domain FE Name.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Volume finite element with switches.
VolumeElementForcesAndSourcesCoreBase::UserDataOperator UserDataOperator
MyStorage(VectorInt &data)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
OpVolumeAssemble(const std::string &field_name, Vec v)
Operator set cache stored data, in this example, global indices, but it can be any structure.
boost::shared_ptr< MyStorage > SharedVecInt
OpVolumeSet(const std::string &field_name)
static std::vector< SharedVecInt > entsIndices
This is global static storage.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
Test if cached data can be accessed, and check consistency of data.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
OpVolumeTest(const std::string &field_name)
int operator()(int, int, int) const
int main(int argc, char *argv[])
FaceEle::UserDataOperator FaceOp