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,
128 DataForcesAndSourcesCore::EntData &row_data,
129 DataForcesAndSourcesCore::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 getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(
142 row_data.getIndices()[0]);
143 const FENumeredDofEntity *dof_ptr;
144 if(
auto ptr = weak_ptr_dof.lock())
149 int rank = dof_ptr->getNbOfCoeffs();
151 K.resize(nb_row/rank,nb_col/rank);
154 for(
unsigned int gg = 0;gg<row_data.getN().size1();gg++) {
157 area = norm_2(getNormalsAtGaussPts(gg))*0.5;
161 double val = getGaussPts()(2,gg)*area;
162 noalias(
K) += val*outer_prod(
163 row_data.getN(gg,nb_row/rank),col_data.getN(gg,nb_col/rank)
167 VectorInt row_indices,col_indices;
168 row_indices.resize(nb_row/rank);
169 col_indices.resize(nb_col/rank);
171 for(
int rr = 0;rr < rank; rr++) {
172 unsigned int nb_rows;
173 unsigned int nb_cols;
178 ublas::noalias(row_indices) = ublas::vector_slice<VectorInt >
179 (row_data.getIndices(), ublas::slice(rr, rank, row_data.getIndices().size()/rank));
181 ublas::noalias(col_indices) = ublas::vector_slice<VectorInt >
182 (col_data.getIndices(), ublas::slice(rr, rank, col_data.getIndices().size()/rank));
184 nb_rows = row_indices.size();
185 nb_cols = col_indices.size();
186 rows = &*row_indices.data().begin();
187 cols = &*col_indices.data().begin();
191 nb_rows = row_data.getIndices().size();
192 nb_cols = col_data.getIndices().size();
193 rows = &*row_data.getIndices().data().begin();
194 cols = &*col_data.getIndices().data().begin();
199 ierr = MatSetValues(
Aij,nb_rows,rows,nb_cols,cols,&
K(0,0),ADD_VALUES); CHKERRQ(
ierr);
202 transK.resize(nb_col/rank,nb_row/rank);
204 ierr = MatSetValues(
Aij,nb_cols,cols,nb_rows,rows,&
transK(0,0),ADD_VALUES); CHKERRQ(
ierr);
208 }
catch (
const std::exception& ex) {
210 ss <<
"throw in method: " << ex.what() << endl;
211 SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
214 PetscFunctionReturn(0);
218 struct OpDmatRhs:
public FaceElementForcesAndSourcesCore::UserDataOperator {
224 const string field_name,
const string lagrang_field_name,
242 for(
unsigned int gg = 0;gg<data.getN().size1();gg++) {
246 area = norm_2(getNormalsAtGaussPts(gg))*0.5;
250 double val = getGaussPts()(2,gg)*area;
252 x = getCoordsAtGaussPts()(gg,0);
253 y = getCoordsAtGaussPts()(gg,1);
254 z = getCoordsAtGaussPts()(gg,2);
258 X_mat.resize(3,6,
false);
266 X_mat.resize(3,3,
false);
271 SETERRQ(PETSC_COMM_SELF,1,
"not implemented");
274 int shape_size = data.getN().size2();
281 for(
int ii=0; ii<shape_size; ii++){
283 double val = data.getN()(gg,ii);
284 for(
int jj=0; jj<
rank; jj++) {
298 PetscFunctionReturn(0);
311 const string field_name,
const string lagrang_field_name,
312 Vec
f, VectorDouble given_strain, boost::ptr_vector<MethodForForceScaling> &methods_op,
RVEBC_Data &data,
bool ho_geometry =
false
323 if(
dAta.
tRis.find(getNumeredEntFiniteElementPtr()->getEnt())==
dAta.
tRis.end()) PetscFunctionReturn(0);
326 getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(
327 data.getIndices()[0]);
328 const FENumeredDofEntity *dof_ptr;
329 if (
auto ptr = weak_ptr_dof.lock())
334 rank = dof_ptr->getNbOfCoeffs();
340 VectorDouble scaled_given_strain;
341 scaled_given_strain.resize(6);
346 f.resize(
D_mat.size1(),
false);
347 noalias(
f) = prod(
D_mat, scaled_given_strain);
355 if(
F == PETSC_NULL) {
356 myF = getFEMethod()->snes_f;
359 ierr = VecSetValues(myF,data.getIndices().size(),&data.getIndices()[0],&
f[0],ADD_VALUES); CHKERRQ(
ierr);
360 PetscFunctionReturn(0);
370 const string field_name,
const string lagrang_field_name,
371 vector<Vec> &
f,
RVEBC_Data &data,
bool ho_geometry =
false
382 if(
dAta.
tRis.find(getNumeredEntFiniteElementPtr()->getEnt())==
dAta.
tRis.end()) PetscFunctionReturn(0);
385 getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(
386 data.getIndices()[0]);
387 const FENumeredDofEntity *dof_ptr;
388 if (
auto ptr = weak_ptr_dof.lock())
393 rank = dof_ptr->getNbOfCoeffs();
399 f.resize(
D_mat.size1(),
false);
401 int size = (
rank == 3) ? 6 : 3;
402 for(
int ii = 0;ii<size;ii++) {
407 F[ii],data.getIndices().size(),&data.getIndices()[0],&
f[0],ADD_VALUES
411 PetscFunctionReturn(0);
417 PetscErrorCode
shapeMat(
int rank,
unsigned int gg, DataForcesAndSourcesCore::EntData &col_data, MatrixDouble &N_mat) {
419 int shape_size=col_data.getN().size2();
422 N_mat.resize(rank,shape_size*rank); N_mat.clear();
424 for(
int ii=0; ii<shape_size; ii++){
425 for(
int jj=0; jj<rank; jj++){
427 N_mat(jj,kk)=col_data.getN()(gg,gg1); kk++;
431 PetscFunctionReturn(0);
447 const string field_name,
const string lagrang_field_name, Vec f,
463 int row_side,
int col_side,
465 DataForcesAndSourcesCore::EntData &row_data,
466 DataForcesAndSourcesCore::EntData &col_data
471 int nb_row = row_data.getIndices().size();
472 int nb_col = col_data.getIndices().size();
474 if(nb_row == 0) PetscFunctionReturn(0);
475 if(nb_col == 0) PetscFunctionReturn(0);
478 getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(
479 row_data.getIndices()[0]);
480 const FENumeredDofEntity *dof_ptr;
481 if (
auto ptr = weak_ptr_dof.lock())
486 int rank = dof_ptr->getNbOfCoeffs();
488 for(
unsigned int gg = 0;gg<row_data.getN().size1();gg++) {
491 area = norm_2(getNormalsAtGaussPts(gg))*0.5;
495 double val = getGaussPts()(2,gg)*area;
511 CU=prod(
K, col_data.getFieldData());
512 CTLam=prod(trans(
K),row_data.getFieldData());
516 if(
F == PETSC_NULL) {
517 myF = getFEMethod()->snes_f;
520 ierr = VecSetValues(myF,row_data.getIndices().size(),&row_data.getIndices()[0],&
CU[0],ADD_VALUES); CHKERRQ(
ierr);
521 ierr = VecSetValues(myF,col_data.getIndices().size(),&col_data.getIndices()[0],&
CTLam[0],ADD_VALUES); CHKERRQ(
ierr);
523 }
catch (
const std::exception& ex) {
525 ss <<
"throw in method: " << ex.what() << endl;
526 SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
529 PetscFunctionReturn(0);
537 string lagrang_field_name,
538 string mesh_nodals_positions,
539 Mat aij,vector<Vec> &fvec,Vec f,VectorDouble given_strain
543 bool ho_geometry =
false;
547 map<int,RVEBC_Data>::iterator sit =
setOfRVEBC.begin();
576 PetscFunctionReturn(0);
582 string lagrang_field_name,
583 string mesh_nodals_positions,
584 Mat aij,vector<Vec> &fvec
588 bool ho_geometry =
false;
592 map<int,RVEBC_Data>::iterator sit =
setOfRVEBC.begin();
605 PetscFunctionReturn(0);
616 const string lagrang_field_name,
619 bool ho_geometry =
false
629 if(data.getIndices().size()==0) PetscFunctionReturn(0);
630 if(
dAta.
tRis.find(getNumeredEntFiniteElementPtr()->getEnt())==
dAta.
tRis.end()) PetscFunctionReturn(0);
635 getNumeredEntFiniteElementPtr()->getRowDofsByPetscGlobalDofIdx(
636 data.getIndices()[0]);
637 const FENumeredDofEntity *dof_ptr;
638 if (
auto ptr = weak_ptr_dof.lock())
643 rank = dof_ptr->getNbOfCoeffs();
654 const int Indices6[6] = {0, 1, 2, 3, 4, 5};
655 const int Indices3[3] = {0, 1, 2};
664 SETERRQ(PETSC_COMM_SELF,1,
"not implemented");
667 PetscFunctionReturn(0);
673 string lagrang_field_name,
674 string mesh_nodals_positions,
679 bool ho_geometry =
false;
684 map<int,RVEBC_Data>::iterator sit =
setOfRVEBC.begin();
689 PetscFunctionReturn(0);
ForcesAndSourcesCore::UserDataOperator UserDataOperator
static PetscErrorCode ierr
#define CHKERRQ_MOAB(a)
check error code of MoAB function
@ MOFEM_DATA_INCONSISTENCY
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_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
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 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, DataForcesAndSourcesCore::EntData &col_data, MatrixDouble &N_mat)
MyTriFE(MoFEM::Interface &_mField)
PetscErrorCode calculateDmat(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
OpDmatRhs(const string field_name, const string lagrang_field_name, RVEBC_Data &data, bool ho_geometry=false)
VectorDouble applied_strain
\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, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::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
PetscErrorCode doWork(int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
CommonFunctions commonFunctions
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, DataForcesAndSourcesCore::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, DataForcesAndSourcesCore::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, DataForcesAndSourcesCore::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.