1 #ifndef __POISSON2DNONHOMOGENEOUS_HPP__
2 #define __POISSON2DNONHOMOGENEOUS_HPP__
18 typedef boost::function<
double(
const double,
const double,
const double)>
23 OpDomainLhs(std::string row_field_name, std::string col_field_name)
29 EntityType col_type,
EntData &row_data,
33 const int nb_row_dofs = row_data.
getIndices().size();
34 const int nb_col_dofs = col_data.
getIndices().size();
36 if (nb_row_dofs && nb_col_dofs) {
38 locLhs.resize(nb_row_dofs, nb_col_dofs,
false);
42 const double area = getMeasure();
45 const int nb_integration_points = getGaussPts().size2();
47 auto t_w = getFTensor0IntegrationWeight();
53 for (
int gg = 0; gg != nb_integration_points; gg++) {
55 const double a = t_w * area;
57 for (
int rr = 0; rr != nb_row_dofs; ++rr) {
61 for (
int cc = 0; cc != nb_col_dofs; cc++) {
63 locLhs(rr, cc) += t_row_diff_base(
i) * t_col_diff_base(
i) *
a;
80 CHKERR MatSetValues<MoFEM::EssentialBcStorage>(
81 getKSPB(), row_data, col_data, &locLhs(0, 0), ADD_VALUES);
84 if (row_side != col_side || row_type != col_type) {
85 transLocLhs.resize(nb_col_dofs, nb_row_dofs,
false);
86 noalias(transLocLhs) = trans(locLhs);
87 CHKERR MatSetValues<MoFEM::EssentialBcStorage>(
88 getKSPB(), col_data, row_data, &transLocLhs(0, 0), ADD_VALUES);
106 sourceTermFunc(source_term_function) {}
115 locRhs.resize(nb_dofs,
false);
119 const double area = getMeasure();
122 const int nb_integration_points = getGaussPts().size2();
124 auto t_w = getFTensor0IntegrationWeight();
126 auto t_coords = getFTensor1CoordsAtGaussPts();
132 for (
int gg = 0; gg != nb_integration_points; gg++) {
134 const double a = t_w * area;
136 sourceTermFunc(t_coords(0), t_coords(1), t_coords(2));
138 for (
int rr = 0; rr != nb_dofs; rr++) {
140 locRhs[rr] += t_base * body_source *
a;
153 CHKERR VecSetValues<MoFEM::EssentialBcStorage>(
154 getKSPf(), data, &*locRhs.begin(), ADD_VALUES);
175 EntityType col_type,
EntData &row_data,
179 const int nb_row_dofs = row_data.
getIndices().size();
180 const int nb_col_dofs = col_data.
getIndices().size();
182 if (nb_row_dofs && nb_col_dofs) {
184 locBoundaryLhs.resize(nb_row_dofs, nb_col_dofs,
false);
185 locBoundaryLhs.clear();
188 const double edge = getMeasure();
191 const int nb_integration_points = getGaussPts().size2();
193 auto t_w = getFTensor0IntegrationWeight();
199 for (
int gg = 0; gg != nb_integration_points; gg++) {
200 const double a = t_w * edge;
202 for (
int rr = 0; rr != nb_row_dofs; ++rr) {
206 for (
int cc = 0; cc != nb_col_dofs; cc++) {
208 locBoundaryLhs(rr, cc) += t_row_base * t_col_base *
a;
222 CHKERR MatSetValues<MoFEM::EssentialBcStorage>(
223 getKSPB(), row_data, col_data, &locBoundaryLhs(0, 0), ADD_VALUES);
224 if (row_side != col_side || row_type != col_type) {
225 transLocBoundaryLhs.resize(nb_col_dofs, nb_row_dofs,
false);
226 noalias(transLocBoundaryLhs) = trans(locBoundaryLhs);
227 CHKERR MatSetValues<MoFEM::EssentialBcStorage>(
228 getKSPB(), col_data, row_data, &transLocBoundaryLhs(0, 0),
246 boundaryFunc(boundary_function) {}
255 locBoundaryRhs.resize(nb_dofs,
false);
256 locBoundaryRhs.clear();
259 const double edge = getMeasure();
262 const int nb_integration_points = getGaussPts().size2();
264 auto t_w = getFTensor0IntegrationWeight();
266 auto t_coords = getFTensor1CoordsAtGaussPts();
272 for (
int gg = 0; gg != nb_integration_points; gg++) {
274 const double a = t_w * edge;
275 double boundary_term =
276 boundaryFunc(t_coords(0), t_coords(1), t_coords(2));
278 for (
int rr = 0; rr != nb_dofs; rr++) {
280 locBoundaryRhs[rr] += t_base * boundary_term *
a;
293 CHKERR VecSetValues<MoFEM::EssentialBcStorage>(
294 getKSPf(), data, &*locBoundaryRhs.begin(), ADD_VALUES);
307 #endif //__POISSON2DNONHOMOGENEOUS_HPP__