30 const std::vector<bool> &periodic,
const PetscInt &window,
37 const PetscInt &kernelSize,
40 PetscFunctionBeginUser;
45 std::vector<bool> periodic(mesh->dim);
46 for (PetscInt d = 0; d < mesh->dim; ++d)
53 ierr = MatCreate(mesh->comm, &Op); CHKERRQ(ierr);
54 ierr = MatSetSizes(Op, bodies->nLclPts * bodies->dim, mesh->UNLocal,
55 bodies->nPts * bodies->dim, mesh->UN); CHKERRQ(ierr);
56 ierr = MatSetFromOptions(Op); CHKERRQ(ierr);
57 ierr = MatSetUp(Op); CHKERRQ(ierr);
59 Op, MAT_KEEP_NONZERO_PATTERN, PETSC_FALSE); CHKERRQ(ierr);
61 Op, MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE); CHKERRQ(ierr);
64 for (PetscInt bIdx = 0; bIdx < bodies->nBodies; ++bIdx)
71 std::vector<PetscReal> widths(mesh->dim);
72 for (PetscInt d = 0; d < mesh->dim; ++d)
76 widths[d] = mesh->dL[0][d][body->meshIdx[0][d]];
80 for (PetscInt iLcl = 0, iGlb = body->bgPt; iLcl < body->nLclPts;
88 for (PetscInt dof = 0; dof < body->dim; ++dof)
95 ierr = bodies->getPackedGlobalIndex(
96 bIdx, iGlb, dof, row); CHKERRQ(ierr);
101 mesh, dof, IJK, periodic, kernelSize, ijk, coords); CHKERRQ(ierr);
106 for (
unsigned int k = 0; k < ijk[2].size(); ++k)
108 xyz[2] = coords[2][k];
109 for (
unsigned int j = 0; j < ijk[1].size(); ++j)
111 xyz[1] = coords[1][j];
112 for (
unsigned int i = 0; i < ijk[0].size(); ++i)
114 xyz[0] = coords[0][i];
117 ierr = mesh->getPackedGlobalIndex(
118 dof, ijk[0][i], ijk[1][j], ijk[2][k],
123 XYZ, xyz, widths, kernel); CHKERRQ(ierr);
131 else if (mesh->dim == 2)
133 for (
unsigned int j = 0; j < ijk[1].size(); ++j)
135 xyz[1] = coords[1][j];
136 for (
unsigned int i = 0; i < ijk[0].size(); ++i)
138 xyz[0] = coords[0][i];
141 ierr = mesh->getPackedGlobalIndex(
142 dof, ijk[0][i], ijk[1][j], 0,
147 XYZ, xyz, widths, kernel); CHKERRQ(ierr);
155 SETERRQ(mesh->comm, PETSC_ERR_ARG_WRONG,
156 "Only 2D and 3D configurations are supported.\n");
158 ierr = MatSetValues(Op, 1, &row,
159 cols.size(), cols.data(), vals.data(),
160 INSERT_VALUES); CHKERRQ(ierr);
165 ierr = MatAssemblyBegin(Op, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
166 ierr = MatAssemblyEnd(Op, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
168 PetscFunctionReturn(0);
173 const std::vector<bool> &periodic,
const PetscInt &window,
176 PetscFunctionBeginUser;
178 xyz.resize(mesh->dim);
179 ijk.resize(mesh->dim);
181 for (PetscInt d = 0; d < mesh->dim; ++d)
183 for (PetscInt s = IJK[d] - window; s <= IJK[d] + window; ++s)
185 if (s >= 0 && s < mesh->n[dof][d])
188 xyz[d].push_back(mesh->coord[dof][d][s]);
190 else if (periodic[d])
192 PetscReal L = mesh->max[d] - mesh->min[d];
195 ijk[d].push_back(s + mesh->n[dof][d]);
196 xyz[d].push_back(mesh->coord[dof][d][s] - L);
200 ijk[d].push_back(s - mesh->n[dof][d]);
201 xyz[d].push_back(mesh->coord[dof][d][s] + L);
207 PetscFunctionReturn(0);
body::BodyPackBase, type::BodyPack, and factory function.
boundary::BoundaryBase, type::Boundary, and factory function.
Prototype of Delta functions.
std::shared_ptr< body::BodyPackBase > BodyPack
Definition of type::BodyPack.
std::shared_ptr< body::SingleBodyBase > SingleBody
Definition of type::SingleBody.
std::shared_ptr< boundary::BoundaryBase > Boundary
Type definition of petibm::type::Boundary.
std::shared_ptr< mesh::MeshBase > Mesh
Type definition of Mesh.
PetscReal delta(const std::vector< PetscReal > &source, const std::vector< PetscReal > &target, const std::vector< PetscReal > &widths, const DeltaKernel &kernel)
Discrete delta function.
PetscErrorCode createDelta(const type::Mesh &mesh, const type::Boundary &bc, const type::BodyPack &bodies, const delta::DeltaKernel &kernel, const PetscInt &kernelSize, Mat &Op)
Create a Delta operator, .
std::vector< IntVec1D > IntVec2D
2D std::vector holding PetscInt.
std::vector< RealVec1D > RealVec2D
2D std::vector holding PetscReal.
std::vector< PetscInt > IntVec1D
1D std::vector holding PetscInt.
std::vector< PetscReal > RealVec1D
1D std::vector holding PetscReal.
Prototype of mesh::MeshBase, type::Mesh, and factory function.
std::function< PetscReal(const PetscReal &r, const PetscReal &dr)> DeltaKernel
Typedef to choose the regularized delta kernel to use.
PetscErrorCode getEulerianNeighbors(const type::Mesh &mesh, const PetscInt &dof, const type::IntVec1D &IJK, const std::vector< bool > &periodic, const PetscInt &window, type::IntVec2D &ijk, type::RealVec2D &xyz)
A toolbox for building flow solvers.
body::SingleBodyBase, type::SingleBody factory function.
Definition of user-defined types for convenience.