DoFs from entities

10 views
Skip to first unread message

ignat...@gmail.com

unread,
Apr 17, 2018, 7:55:24 AM4/17/18
to mofem Group
Hi all,

I would like to access the DoFs sitting on specific entities in my problem.
Could someone suggest an approach to access them?

Thank you in advance,
Ignatios 
 

Lukasz Kaczmraczyk

unread,
Apr 17, 2018, 9:27:29 AM4/17/18
to mofem Group
Hello,

In development version v0.7.16 or later you can find implementation ISManager with isCreateProblemFieldAndRank which allows for getting dofs indices on given entities. 
http://mofem.eng.gla.ac.uk/mofem/html/group__mofem__vectors.html#gae5ec9e148a39f26640926a5cba24ae3a

Here is example how you can use it.

Imagine that you have entities on some surface
Range ents_on_surface;
// get them form sideset/blockset/nodeset

And some discrete manager DM, first we get pointer to the problem in DM,
const MoFEM::Problem *problem_ptr;
CHKERR
DMMoFEMGetProblemPtr(dm, &problem_ptr);

Now we like to extract "x" component of displacement filed 
// get is from problem, see MoFEM documentation
IS
is;
CHKERR m_field
.getInterface<ISManager>()->isCreateProblemFieldAndRank(
  problem_ptr
->getName(),ROW,"DISPLACEMENTS",0,1,&is,&ents_on_surface
);
// create vector with is size
int is_size, is_local_size;
CHKERR
ISGetSize(is,is_size);
CHKERR
ISGetLocalSize(is,is_local_size);
Vec f_with_coeff_0_on_entities;
CHKERR
VecCreateMPI(PETSC_COMM_WORLD,is_local_size,is_size,&f_with_coeff_0_on_entities);
// scatter values from f_internal to f_with_coeff_0_on_entities
VecScatter sct;
CHKERR
VecScatterCreate(f_internal,is,f_with_coeff_0_on_entities,PETSC_NULL,&sct);
CHKERR
VecScatterBegin(sct,f_internal,f_with_coeff_0_on_entities,INSERT_VALUES,SCATTER_FORWARD);
CHKERR
VecScatterEnd(sct,f_internal,f_with_coeff_0_on_entities,INSERT_VALUES,SCATTER_FORWARD);
// calculate sum of vector with dofs in x-element on entities
int sum0;
CHKERR
VecSum(f_with_coeff_0_on_entities,&sum0);


Kind regards,
Lukasz

Reply all
Reply to author
Forward
0 new messages