13 auto pwl_sdm = std::static_pointer_cast<
17 size_t num_nodes = fe_intgrl_values.NumNodes();
22 std::vector<double> D(num_nodes, 1.0);
23 std::vector<double> q(num_nodes, 1.0);
24 std::vector<double> siga(num_nodes, 0.0);
29 for (
int i=0; i<num_nodes; i++)
35 for (
int j=0; j<num_nodes; j++)
40 D[j]* fe_intgrl_values.IntV_gradShapeI_gradShapeJ(i, j);
43 siga[j]* fe_intgrl_values.IntV_shapeI_shapeJ(i, j);
45 MatSetValue(
A_, ir, jr, jr_mat_entry, ADD_VALUES);
47 rhsvalue += q[j]* fe_intgrl_values.IntV_shapeI_shapeJ(i, j);
51 VecSetValue(
b_, ir, rhsvalue, ADD_VALUES);
57 int num_faces = cell.
faces_.size();
58 for (
unsigned int f=0; f<num_faces; f++)
60 auto& face = cell.
faces_[f];
65 int num_face_dofs = face.vertex_ids_.size();
67 if (face.has_neighbor_)
69 const auto& adj_cell =
grid_ptr_->cells[face.neighbor_id_];
70 const auto& adj_fe_intgrl_values =
unit_integrals_.at(adj_cell.global_id_);
79 std::vector<double> adj_D,adj_Q,adj_sigma;
82 adj_fe_intgrl_values.NumNodes(),
91 for (
int fi=0; fi<num_face_dofs; fi++)
93 int i = fe_intgrl_values.FaceDofMapping(f,fi);
94 D_avg += D[i]* fe_intgrl_values.IntS_shapeI(f, i);
95 intS += fe_intgrl_values.IntS_shapeI(f, i);
100 double adj_D_avg = 0.0;
101 double adj_intS = 0.0;
102 for (
int fi=0; fi<num_face_dofs; fi++)
104 int i = fe_intgrl_values.FaceDofMapping(f,fi);
106 adj_D_avg += adj_D[imap]* adj_fe_intgrl_values.IntS_shapeI(fmap, imap);
107 adj_intS += adj_fe_intgrl_values.IntS_shapeI(fmap, imap);
109 adj_D_avg /= adj_intS;
114 kappa = fmax(2.0*(adj_D_avg/hp + D_avg/hm),0.25);
116 kappa = fmax(2.0*(adj_D_avg/hp + D_avg/hm),0.25);
118 kappa = fmax(4.0*(adj_D_avg/hp + D_avg/hm),0.25);
121 for (
int fi=0; fi<num_face_dofs; fi++)
123 int i = fe_intgrl_values.FaceDofMapping(f,fi);
126 for (
int fj=0; fj<num_face_dofs; fj++)
128 int j = fe_intgrl_values.FaceDofMapping(f,fj);
131 int jrmap = pwl_sdm->MapDOF(adj_cell, jmap,
unknown_manager_, 0, component);
133 double aij = kappa* fe_intgrl_values.IntS_shapeI_shapeJ(f, i, j);
135 MatSetValue(
A_, ir , jr , aij, ADD_VALUES);
136 MatSetValue(
A_, ir , jrmap, -aij, ADD_VALUES);
146 for (
int i=0; i<fe_intgrl_values.NumNodes(); i++)
150 for (
int fj=0; fj<num_face_dofs; fj++)
152 int j = fe_intgrl_values.FaceDofMapping(f,fj);
155 int jrmap = pwl_sdm->MapDOF(adj_cell, jmap,
unknown_manager_, 0, component);
158 -0.5*D_avg*n.
Dot(fe_intgrl_values.IntS_shapeI_gradshapeJ(f, j, i));
160 MatSetValue(
A_, ir, jr , aij, ADD_VALUES);
161 MatSetValue(
A_, ir, jrmap, -aij, ADD_VALUES);
166 for (
int fi=0; fi<num_face_dofs; fi++)
168 int i = fe_intgrl_values.FaceDofMapping(f,fi);
171 int irmap = pwl_sdm->MapDOF(adj_cell, imap,
unknown_manager_, 0, component);
173 for (
int j=0; j<fe_intgrl_values.NumNodes(); j++)
178 -0.5*D_avg*n.
Dot(fe_intgrl_values.IntS_shapeI_gradshapeJ(f, i, j));
180 MatSetValue(
A_, ir , jr, aij, ADD_VALUES);
181 MatSetValue(
A_, irmap, jr, -aij, ADD_VALUES);
188 uint64_t ir_boundary_index = face.neighbor_id_;
189 auto ir_boundary_type =
boundaries_.at(ir_boundary_index)->type_;
202 for (
int fi=0; fi<num_face_dofs; fi++)
204 int i = fe_intgrl_values.FaceDofMapping(f,fi);
205 D_avg += D[i]* fe_intgrl_values.IntS_shapeI(f, i);
206 intS += fe_intgrl_values.IntS_shapeI(f, i);
212 kappa = fmax(4.0*(D_avg/hm),0.25);
214 kappa = fmax(4.0*(D_avg/hm),0.25);
216 kappa = fmax(8.0*(D_avg/hm),0.25);
219 for (
int fi=0; fi<num_face_dofs; fi++)
221 int i = fe_intgrl_values.FaceDofMapping(f,fi);
224 for (
int fj=0; fj<num_face_dofs; fj++)
226 int j = fe_intgrl_values.FaceDofMapping(f,fj);
229 double aij = kappa* fe_intgrl_values.IntS_shapeI_shapeJ(f, i, j);
231 MatSetValue(
A_, ir , jr, aij, ADD_VALUES);
232 VecSetValue(
b_, ir, aij * dc_boundary.boundary_value, ADD_VALUES);
238 for (
int i=0; i<fe_intgrl_values.NumNodes(); i++)
242 for (
int j=0; j<fe_intgrl_values.NumNodes(); j++)
247 n.
Dot(fe_intgrl_values.IntS_shapeI_gradshapeJ(f, i, j) +
248 fe_intgrl_values.IntS_shapeI_gradshapeJ(f, j, i));
249 double aij = -0.5*D_avg*gij;
251 MatSetValue(
A_, ir, jr, aij, ADD_VALUES);
252 VecSetValue(
b_, ir, aij * dc_boundary.boundary_value, ADD_VALUES);
261 for (
int fi=0; fi<num_face_dofs; fi++)
263 int i = fe_intgrl_values.FaceDofMapping(f,fi);
266 for (
int fj=0; fj<num_face_dofs; fj++)
268 int j = fe_intgrl_values.FaceDofMapping(f,fj);
271 double aij = robin_bndry.a* fe_intgrl_values.IntS_shapeI_shapeJ(f, i, j);
272 aij /= robin_bndry.b;
274 MatSetValue(
A_, ir , jr, aij, ADD_VALUES);
277 double bi = robin_bndry.f* fe_intgrl_values.IntS_shapeI(f, i);
280 VecSetValue(
b_, ir, bi, ADD_VALUES);
292 auto pwl_sdm = std::static_pointer_cast<
294 const auto& fe_intgrl_values = unit_integrals_.at(cell.
global_id_);
296 size_t num_nodes = fe_intgrl_values.NumNodes();
301 std::vector<double> D(num_nodes, 1.0);
302 std::vector<double> q(num_nodes, 1.0);
303 std::vector<double> siga(num_nodes, 1.0);
305 GetMaterialProperties(cell, num_nodes, D, q, siga, component);
308 for (
int i=0; i<num_nodes; i++)
310 int ir = pwl_sdm->MapDOF(cell, i, unknown_manager_, 0, component);
313 double rhsvalue =0.0;
314 for (
int j=0; j<num_nodes; j++)
315 rhsvalue += q[j]* fe_intgrl_values.IntV_shapeI_shapeJ(i, j);
318 VecSetValue(b_, ir, rhsvalue, ADD_VALUES);
std::map< uint64_t, UnitIntegralContainer > unit_integrals_
static uint64_t MapCellLocalNodeIDFromGlobalID(const chi_mesh::Cell &cell, uint64_t node_global_id)
void GetMaterialProperties(const chi_mesh::Cell &cell, int cell_dofs, std::vector< double > &diffCoeff, std::vector< double > &sourceQ, std::vector< double > &sigmaa, int group=0, int moment=0)
void PWLD_Assemble_b(const chi_mesh::Cell &cell, int component=0)
static unsigned int MapCellFace(const chi_mesh::Cell &cur_cell, const chi_mesh::Cell &adj_cell, unsigned int f)
std::map< uint64_t, chi_diffusion::Boundary * > boundaries_
chi_mesh::MeshContinuumPtr grid_ptr_
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
chi_math::UnknownManager unknown_manager_
double HPerpendicular(const chi_mesh::Cell &cell, const UnitIntegralContainer &fe_intgrl_values, unsigned int f)
void PWLD_Assemble_A_and_b(const chi_mesh::Cell &cell, int component=0)
std::vector< CellFace > faces_
std::vector< uint64_t > vertex_ids_
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const