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);
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,
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)
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();
202 transK.resize(nb_col/rank,nb_row/rank);
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);
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();
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);
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);
463 int row_side,
int col_side,
464 EntityType row_type,EntityType col_type,
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);
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,
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);
693 #endif // __BCS_RVELAGRANGE_DISP_HPP