v0.9.0
Public Member Functions | Public Attributes | List of all members
AnalyticalDirihletBC::ApproxField::OpLhs Struct Reference

Lhs operaetar used to build matrix. More...

#include <users_modules/helmholtz/src/AnalyticalDirihlet_obsolete.hpp>

Inherits UserDataOperator.

Public Member Functions

 OpLhs (const string field_name, MatrixDouble &ho_coords)
 
PetscErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSurcesCore::EntData &row_data, DataForcesAndSurcesCore::EntData &col_data)
 

Public Attributes

MatrixDoublehoCoords
 
ublas::matrix< FieldData > NN
 
ublas::matrix< FieldData > transNN
 

Detailed Description

Lhs operaetar used to build matrix.

Definition at line 93 of file AnalyticalDirihlet_obsolete.hpp.

Constructor & Destructor Documentation

◆ OpLhs()

AnalyticalDirihletBC::ApproxField::OpLhs::OpLhs ( const string  field_name,
MatrixDouble ho_coords 
)

Definition at line 96 of file AnalyticalDirihlet_obsolete.hpp.

96  :
98  hoCoords(ho_coords) { }
ForcesAndSourcesCore::UserDataOperator UserDataOperator

Member Function Documentation

◆ doWork()

PetscErrorCode AnalyticalDirihletBC::ApproxField::OpLhs::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
DataForcesAndSurcesCore::EntData row_data,
DataForcesAndSurcesCore::EntData col_data 
)

Definition at line 101 of file AnalyticalDirihlet_obsolete.hpp.

105  {
106  PetscFunctionBegin;
107 
108  PetscFunctionBegin;
109 
110  if(row_data.getIndices().size()==0) PetscFunctionReturn(0);
111  if(col_data.getIndices().size()==0) PetscFunctionReturn(0);
112 
113  PetscErrorCode ierr;
114 
115  const FENumeredDofMoFEMEntity *dof_ptr;
116  ierr = getMoFEMFEPtr()->get_row_dofs_by_petsc_gloabl_dof_idx(row_data.getIndices()[0],&dof_ptr); CHKERRQ(ierr);
117  int rank = dof_ptr->get_max_rank();
118 
119  int nb_row_dofs = row_data.getIndices().size()/rank;
120  int nb_col_dofs = col_data.getIndices().size()/rank;
121 
122  NN.resize(nb_row_dofs,nb_col_dofs);
123  NN.clear();
124 
125  unsigned int nb_gauss_pts = row_data.getN().size1();
126  for(unsigned int gg = 0;gg<nb_gauss_pts;gg++) {
127 
128  double w = getGaussPts()(2,gg);
129  if(hoCoords.size1() == row_data.getN().size1()) {
130 
131  // higher order element
132  double area = norm_2(getNormals_at_GaussPt(gg))*0.5;
133  w *= area;
134 
135  } else {
136 
137  //linear element
138  w *= getArea();
139 
140  }
141 
143  nb_row_dofs,nb_col_dofs,
144  w,&row_data.getN()(gg,0),1,&col_data.getN()(gg,0),1,
145  &*NN.data().begin(),nb_col_dofs);
146 
147  }
148 
149  if( (row_type != col_type) || (row_side != col_side) ) {
150  transNN.resize(nb_col_dofs,nb_row_dofs);
151  ublas::noalias(transNN) = trans(NN);
152  }
153 
154  double *data = &*NN.data().begin();
155  double *trans_data = &*transNN.data().begin();
156  VectorInt row_indices,col_indices;
157  row_indices.resize(nb_row_dofs);
158  col_indices.resize(nb_col_dofs);
159 
160  for(int rr = 0;rr < rank; rr++) {
161 
162  if((row_data.getIndices().size()%rank)!=0) {
163  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"data inconsistency");
164  }
165 
166  if((col_data.getIndices().size()%rank)!=0) {
167  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"data inconsistency");
168  }
169 
170  unsigned int nb_rows;
171  unsigned int nb_cols;
172  int *rows;
173  int *cols;
174 
175 
176  if(rank > 1) {
177 
178  ublas::noalias(row_indices) = ublas::vector_slice<VectorInt >
179  (row_data.getIndices(), ublas::slice(rr, rank, row_data.getIndices().size()/rank));
180  ublas::noalias(col_indices) = ublas::vector_slice<VectorInt >
181  (col_data.getIndices(), ublas::slice(rr, rank, col_data.getIndices().size()/rank));
182 
183  nb_rows = row_indices.size();
184  nb_cols = col_indices.size();
185  rows = &*row_indices.data().begin();
186  cols = &*col_indices.data().begin();
187 
188  } else {
189 
190  nb_rows = row_data.getIndices().size();
191  nb_cols = col_data.getIndices().size();
192  rows = &*row_data.getIndices().data().begin();
193  cols = &*col_data.getIndices().data().begin();
194 
195  }
196 
197  if(nb_rows != NN.size1()) {
198  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"data inconsistency");
199  }
200  if(nb_cols != NN.size2()) {
201  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"data inconsistency");
202  }
203 
204  ierr = MatSetValues(getFEMethod()->snes_B,nb_rows,rows,nb_cols,cols,data,ADD_VALUES); CHKERRQ(ierr);
205  if( (row_type != col_type) || (row_side != col_side) ) {
206  if(nb_rows != transNN.size2()) {
207  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"data inconsistency");
208  }
209  if(nb_cols != transNN.size1()) {
210  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCT,"data inconsistency");
211  }
212  ierr = MatSetValues(getFEMethod()->snes_B,nb_cols,cols,nb_rows,rows,trans_data,ADD_VALUES); CHKERRQ(ierr);
213  }
214 
215  }
216 
217  PetscFunctionReturn(0);
218  }
void cblas_dger(const enum CBLAS_ORDER order, const int M, const int N, const double alpha, const double *X, const int incX, const double *Y, const int incY, double *A, const int lda)
Definition: cblas_dger.c:12
CHKERRQ(ierr)
MoFEMErrorCode MatSetValues(Mat M, const DataForcesAndSourcesCore::EntData &row_data, const DataForcesAndSourcesCore::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
ublas::vector< int, IntAllocator > VectorInt
Definition: Types.hpp:71

Member Data Documentation

◆ hoCoords

MatrixDouble& AnalyticalDirihletBC::ApproxField::OpLhs::hoCoords

Definition at line 95 of file AnalyticalDirihlet_obsolete.hpp.

◆ NN

ublas::matrix<FieldData> AnalyticalDirihletBC::ApproxField::OpLhs::NN

Definition at line 100 of file AnalyticalDirihlet_obsolete.hpp.

◆ transNN

ublas::matrix<FieldData> AnalyticalDirihletBC::ApproxField::OpLhs::transNN

Definition at line 100 of file AnalyticalDirihlet_obsolete.hpp.


The documentation for this struct was generated from the following file: