15#ifndef __BCS_RVELAGRANGE_DISP_HPP
16#define __BCS_RVELAGRANGE_DISP_HPP
59 const string element_name,
61 const string lagrang_field_name,
62 const string mesh_nodals_positions
90 if(it->getName().compare(0,12,
"AllBoundSurf") == 0 || it->getMeshsetId() == 103) {
97 PetscFunctionReturn(0);
101 struct OpRVEBCsLhs:
public FaceElementForcesAndSourcesCore::UserDataOperator {
107 const string field_name,
const string lagrang_field_name, Mat aij,
126 int row_side,
int col_side,
127 EntityType row_type,EntityType col_type,
128 DataForcesAndSurcesCore::EntData &row_data,
129 DataForcesAndSurcesCore::EntData &col_data
134 int nb_row = row_data.getIndices().size();
135 int nb_col = col_data.getIndices().size();
137 if(nb_row == 0) PetscFunctionReturn(0);
138 if(nb_col == 0) PetscFunctionReturn(0);
141 const FENumeredDofEntity *dof_ptr;
142 ierr = getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(row_data.getIndices()[0],&dof_ptr); CHKERRQ(
ierr);
143 int rank = dof_ptr->getNbOfCoeffs();
145 K.resize(nb_row/rank,nb_col/rank);
148 for(
unsigned int gg = 0;gg<row_data.getN().size1();gg++) {
151 area = norm_2(getNormalsAtGaussPt(gg))*0.5;
155 double val = getGaussPts()(2,gg)*area;
156 noalias(
K) += val*outer_prod(
157 row_data.getN(gg,nb_row/rank),col_data.getN(gg,nb_col/rank)
161 VectorInt row_indices,col_indices;
162 row_indices.resize(nb_row/rank);
163 col_indices.resize(nb_col/rank);
165 for(
int rr = 0;rr < rank; rr++) {
166 unsigned int nb_rows;
167 unsigned int nb_cols;
172 ublas::noalias(row_indices) = ublas::vector_slice<VectorInt >
173 (row_data.getIndices(), ublas::slice(rr, rank, row_data.getIndices().size()/rank));
175 ublas::noalias(col_indices) = ublas::vector_slice<VectorInt >
176 (col_data.getIndices(), ublas::slice(rr, rank, col_data.getIndices().size()/rank));
178 nb_rows = row_indices.size();
179 nb_cols = col_indices.size();
180 rows = &*row_indices.data().begin();
181 cols = &*col_indices.data().begin();
185 nb_rows = row_data.getIndices().size();
186 nb_cols = col_data.getIndices().size();
187 rows = &*row_data.getIndices().data().begin();
188 cols = &*col_data.getIndices().data().begin();
193 ierr = MatSetValues(
Aij,nb_rows,rows,nb_cols,cols,&
K(0,0),ADD_VALUES); CHKERRQ(
ierr);
196 transK.resize(nb_col/rank,nb_row/rank);
198 ierr = MatSetValues(
Aij,nb_cols,cols,nb_rows,rows,&
transK(0,0),ADD_VALUES); CHKERRQ(
ierr);
202 }
catch (
const std::exception& ex) {
204 ss <<
"throw in method: " << ex.what() << endl;
205 SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
208 PetscFunctionReturn(0);
212 struct OpDmatRhs:
public FaceElementForcesAndSourcesCore::UserDataOperator {
218 const string field_name,
const string lagrang_field_name,
232 PetscErrorCode
calculateDmat(
int side,EntityType type,DataForcesAndSurcesCore::EntData &data) {
236 for(
unsigned int gg = 0;gg<data.getN().size1();gg++) {
240 area = norm_2(getNormalsAtGaussPt(gg))*0.5;
244 double val = getGaussPts()(2,gg)*area;
246 x = getHoCoordsAtGaussPts()(gg,0);
247 y = getHoCoordsAtGaussPts()(gg,1);
248 z = getHoCoordsAtGaussPts()(gg,2);
252 X_mat.resize(3,6,
false);
260 X_mat.resize(3,3,
false);
265 SETERRQ(PETSC_COMM_SELF,1,
"not implemented");
268 int shape_size = data.getN().size2();
275 for(
int ii=0; ii<shape_size; ii++){
277 double val = data.getN()(gg,ii);
278 for(
int jj=0; jj<
rank; jj++) {
292 PetscFunctionReturn(0);
305 const string field_name,
const string lagrang_field_name,
306 Vec
f, VectorDouble given_strain, boost::ptr_vector<MethodForForceScaling> &methods_op,
RVEBC_Data &data,
bool ho_geometry =
false
311 PetscErrorCode
doWork(
int side,EntityType type,DataForcesAndSurcesCore::EntData &data) {
317 if(
dAta.
tRis.find(getNumeredEntFiniteElementPtr()->getEnt())==
dAta.
tRis.end()) PetscFunctionReturn(0);
320 const FENumeredDofEntity *dof_ptr;
321 ierr = getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(data.getIndices()[0],&dof_ptr); CHKERRQ(
ierr);
322 rank = dof_ptr->getNbOfCoeffs();
328 VectorDouble scaled_given_strain;
329 scaled_given_strain.resize(6);
334 f.resize(
D_mat.size1(),
false);
335 noalias(
f) = prod(
D_mat, scaled_given_strain);
343 if(
F == PETSC_NULL) {
344 myF = getFEMethod()->snes_f;
347 ierr = VecSetValues(myF,data.getIndices().size(),&data.getIndices()[0],&
f[0],ADD_VALUES); CHKERRQ(
ierr);
348 PetscFunctionReturn(0);
358 const string field_name,
const string lagrang_field_name,
359 vector<Vec> &
f,
RVEBC_Data &data,
bool ho_geometry =
false
364 PetscErrorCode
doWork(
int side,EntityType type,DataForcesAndSurcesCore::EntData &data) {
370 if(
dAta.
tRis.find(getNumeredEntFiniteElementPtr()->getEnt())==
dAta.
tRis.end()) PetscFunctionReturn(0);
373 const FENumeredDofEntity *dof_ptr;
374 ierr = getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(data.getIndices()[0],&dof_ptr); CHKERRQ(
ierr);
375 rank = dof_ptr->getNbOfCoeffs();
381 f.resize(
D_mat.size1(),
false);
383 int size = (
rank == 3) ? 6 : 3;
384 for(
int ii = 0;ii<size;ii++) {
389 F[ii],data.getIndices().size(),&data.getIndices()[0],&
f[0],ADD_VALUES
393 PetscFunctionReturn(0);
399 PetscErrorCode
shapeMat(
int rank,
unsigned int gg, DataForcesAndSurcesCore::EntData &col_data, MatrixDouble &N_mat) {
401 int shape_size=col_data.getN().size2();
404 N_mat.resize(rank,shape_size*rank); N_mat.clear();
406 for(
int ii=0; ii<shape_size; ii++){
407 for(
int jj=0; jj<rank; jj++){
409 N_mat(jj,kk)=col_data.getN()(gg,gg1); kk++;
413 PetscFunctionReturn(0);
429 const string field_name,
const string lagrang_field_name, Vec f,
445 int row_side,
int col_side,
446 EntityType row_type,EntityType col_type,
447 DataForcesAndSurcesCore::EntData &row_data,
448 DataForcesAndSurcesCore::EntData &col_data
453 int nb_row = row_data.getIndices().size();
454 int nb_col = col_data.getIndices().size();
456 if(nb_row == 0) PetscFunctionReturn(0);
457 if(nb_col == 0) PetscFunctionReturn(0);
461 const FENumeredDofEntity *dof_ptr;
462 ierr = getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(row_data.getIndices()[0],&dof_ptr); CHKERRQ(
ierr);
463 int rank = dof_ptr->getNbOfCoeffs();
464 for(
unsigned int gg = 0;gg<row_data.getN().size1();gg++) {
467 area = norm_2(getNormalsAtGaussPt(gg))*0.5;
471 double val = getGaussPts()(2,gg)*area;
487 CU=prod(
K, col_data.getFieldData());
488 CTLam=prod(trans(
K),row_data.getFieldData());
492 if(
F == PETSC_NULL) {
493 myF = getFEMethod()->snes_f;
496 ierr = VecSetValues(myF,row_data.getIndices().size(),&row_data.getIndices()[0],&
CU[0],ADD_VALUES); CHKERRQ(
ierr);
497 ierr = VecSetValues(myF,col_data.getIndices().size(),&col_data.getIndices()[0],&
CTLam[0],ADD_VALUES); CHKERRQ(
ierr);
499 }
catch (
const std::exception& ex) {
501 ss <<
"throw in method: " << ex.what() << endl;
502 SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
505 PetscFunctionReturn(0);
513 string lagrang_field_name,
514 string mesh_nodals_positions,
515 Mat aij,vector<Vec> &fvec,Vec f,VectorDouble given_strain
519 bool ho_geometry =
false;
523 map<int,RVEBC_Data>::iterator sit =
setOfRVEBC.begin();
552 PetscFunctionReturn(0);
558 string lagrang_field_name,
559 string mesh_nodals_positions,
560 Mat aij,vector<Vec> &fvec
564 bool ho_geometry =
false;
568 map<int,RVEBC_Data>::iterator sit =
setOfRVEBC.begin();
581 PetscFunctionReturn(0);
592 const string lagrang_field_name,
595 bool ho_geometry =
false
603 PetscErrorCode
doWork(
int side,EntityType type,DataForcesAndSurcesCore::EntData &data) {
605 if(data.getIndices().size()==0) PetscFunctionReturn(0);
606 if(
dAta.
tRis.find(getNumeredEntFiniteElementPtr()->getEnt())==
dAta.
tRis.end()) PetscFunctionReturn(0);
610 const FENumeredDofEntity *dof_ptr;
611 ierr = getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(data.getIndices()[0],&dof_ptr); CHKERRQ(
ierr);
612 rank = dof_ptr->getNbOfCoeffs();
623 const int Indices6[6] = {0, 1, 2, 3, 4, 5};
624 const int Indices3[3] = {0, 1, 2};
633 SETERRQ(PETSC_COMM_SELF,1,
"not implemented");
636 PetscFunctionReturn(0);
642 string lagrang_field_name,
643 string mesh_nodals_positions,
648 bool ho_geometry =
false;
653 map<int,RVEBC_Data>::iterator sit =
setOfRVEBC.begin();
658 PetscFunctionReturn(0);
static PetscErrorCode ierr
#define CHKERRQ_MOAB(a)
check error code of MoAB function
constexpr int order
Order displacement.
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_field)=0
set finite element field data
virtual bool check_field(const std::string &name) const =0
check if field is in database
#define _IT_CUBITMESHSETS_BY_SET_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet having a particular BC meshset in a moFEM field.
constexpr auto field_name
PetscErrorCode shapeMat(int rank, unsigned int gg, DataForcesAndSurcesCore::EntData &col_data, MatrixDouble &N_mat)
MyTriFE(MoFEM::Interface &_mField)
OpDmatRhs(const string field_name, const string lagrang_field_name, RVEBC_Data &data, bool ho_geometry=false)
VectorDouble applied_strain
PetscErrorCode calculateDmat(int side, EntityType type, DataForcesAndSurcesCore::EntData &data)
\biref operator to calculate the LHS for the RVE bounary conditions
PetscErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSurcesCore::EntData &row_data, DataForcesAndSurcesCore::EntData &col_data)
calculate thermal convection term in the lhs of equations
OpRVEBCsLhs(const string field_name, const string lagrang_field_name, Mat aij, RVEBC_Data &data, bool ho_geometry=false)
\biref operator to calculate and assemble CU
CommonFunctions commonFunctions
PetscErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSurcesCore::EntData &row_data, DataForcesAndSurcesCore::EntData &col_data)
OpRVEBCsRhsForceExternal_CU(const string field_name, const string lagrang_field_name, Vec f, CommonFunctions &_common_functions, RVEBC_Data &data, bool ho_geometry=false)
\biref operator to calculate the RHS for the calculation of the homgoensied stiffness matrix
OpRVEBCsRhsHomoC(const string field_name, const string lagrang_field_name, vector< Vec > &f, RVEBC_Data &data, bool ho_geometry=false)
PetscErrorCode doWork(int side, EntityType type, DataForcesAndSurcesCore::EntData &data)
\biref operator to calculate the RHS of the constrain for the RVE boundary conditions
OpRVEBCsRhs(const string field_name, const string lagrang_field_name, Vec f, VectorDouble given_strain, boost::ptr_vector< MethodForForceScaling > &methods_op, RVEBC_Data &data, bool ho_geometry=false)
PetscErrorCode doWork(int side, EntityType type, DataForcesAndSurcesCore::EntData &data)
boost::ptr_vector< MethodForForceScaling > & methodsOp
\biref operator to calculate the RVE homogenised stress
VectorDouble Stress_Homo_elem
PetscErrorCode doWork(int side, EntityType type, DataForcesAndSurcesCore::EntData &data)
OpRVEHomoStress(const string field_name, const string lagrang_field_name, Vec stress_homo, RVEBC_Data &data, bool ho_geometry=false)
map< int, RVEBC_Data > setOfRVEBC
maps side set id with appropriate FluxData
MyTriFE & getLoopFeRVEBCLhs()
BCs_RVELagrange_Disp(MoFEM::Interface &m_field)
boost::ptr_vector< MethodForForceScaling > methodsOp
MyTriFE & getLoopFeRVEBCRhs()
CommonFunctions common_functions
PetscErrorCode setRVEBCsOperatorsNonlinear(string field_name, string lagrang_field_name, string mesh_nodals_positions, Mat aij, vector< Vec > &fvec, Vec f, VectorDouble given_strain)
MyTriFE & getLoopFeRVEBCRhsHomoC()
MyTriFE feRVEBCRhsResidual
PetscErrorCode setRVEBCsHomoStressOperators(string field_name, string lagrang_field_name, string mesh_nodals_positions, Vec Stress_Homo)
MoFEM::Interface & mField
MyTriFE & getLoopFeRVEBCStress()
MyTriFE & getLoopFeRVEBCRhsResidual()
PetscErrorCode setRVEBCsOperators(string field_name, string lagrang_field_name, string mesh_nodals_positions, Mat aij, vector< Vec > &fvec)
PetscErrorCode addLagrangiangElement(const string element_name, const string field_name, const string lagrang_field_name, const string mesh_nodals_positions)
static MoFEMErrorCode applyScale(const FEMethod *fe, boost::ptr_vector< MethodForForceScaling > &methods_op, VectorDouble &nf)
virtual moab::Interface & get_moab()=0
Deprecated interface functions.