10 #ifndef DENDRO_5_0_FEVECTOR_H 11 #define DENDRO_5_0_FEVECTOR_H 27 VECType * m_uiEleVecOut;
55 virtual void computeVec(
const VECType* in,VECType* out,
double scale=1.0);
63 virtual void elementalComputVec(
const VECType* in,VECType* out,
double* coords=NULL,
double scale=1.0)=0;
65 #ifdef BUILD_WITH_PETSC 73 virtual void computeVec(
const Vec& in,Vec& out,
double scale=1.0);
78 T& asLeaf() {
return static_cast<T&
>(*this);}
80 bool preComputeVec(
const VECType* in, VECType* out,
double scale=1.0) {
81 return asLeaf().preComputeVec(in,out,scale);
84 bool postComputeVec(
const VECType* in, VECType* out,
double scale=1.0) {
85 return asLeaf().postComputeVec(in,out,scale);
88 bool preEvalVec(
const VECType* in, VECType* out,
double scale=1.0) {
89 return asLeaf().preEvalVec(in,out,scale);
92 bool postEvalVec(
const VECType* in, VECType* out,
double scale=1.0) {
93 return asLeaf().postEvalVec(in,out,scale);
103 m_uiEleVecIn =
new VECType[m_uiDof*nPe];
104 m_uiEleVecOut =
new VECType[m_uiDof*nPe];
106 m_uiEleCoords=
new double[m_uiDim*nPe];
109 template <
typename T>
113 delete [] m_uiEleVecOut;
119 template <
typename T>
130 preComputeVec(in,out,scale);
135 VECType * val=
new VECType[
m_uiDof];
136 for(
unsigned int var=0;var<
m_uiDof;var++)
146 double * qMat =
new double[nPe*nPe];
147 const unsigned int * e2n_cg = &(*(pMesh->
getE2NMapping().begin()));
159 for (
unsigned int dof = 0; dof <
m_uiDof; dof++) {
160 for (
unsigned int i = 0; i < nPe; i++) {
161 VECType ss = (VECType) 0;
162 for (
unsigned int j = 0; j < nPe; j++) {
163 ss += qMat[j * nPe + i] * m_uiEleVecOut[dof*nPe + j];
165 _out[dof*totalNodalSize + e2n_cg[currentId * nPe + i]] += (VECType) ss;
175 const unsigned int eleLocalEnd = pMesh -> getElementLocalEnd();
189 for (
unsigned int dof = 0; dof <
m_uiDof; dof++) {
190 for (
unsigned int i = 0; i < nPe; i++) {
191 VECType ss = (VECType) 0;
192 for (
unsigned int j = 0; j < nPe; j++) {
193 ss += qMat[j * nPe + i] * m_uiEleVecOut[dof*nPe + j];
195 _out[dof*totalNodalSize + e2n_cg[currentId * nPe + i]] += (VECType) ss;
213 postComputeVec(in,out,scale);
221 #ifdef BUILD_WITH_PETSC 224 template <
typename T>
227 const PetscScalar * inArry=NULL;
228 PetscScalar * outArry=NULL;
230 VecGetArrayRead(in,&inArry);
231 VecGetArray(out,&outArry);
235 VecRestoreArrayRead(in,&inArry);
236 VecRestoreArray(out,&outArry);
241 #endif //DENDRO_5_0_FEVECTOR_H unsigned int getNumNodesPerElement() const
get number of nodes per element
Definition: oda.h:257
void getElementQMat(unsigned int currentId, double *&qMat, bool isAllocated=true) const
: Compute the elemental interpolation matrix.
Definition: mesh.cpp:9436
feVec.h abstract interface based on Dendro 4. feVec contains an abstract interface to perform FEM acc...
virtual void computeVec(const VECType *in, VECType *out, double scale=1.0)
Evaluates the RHS of the PDE at specific points (for example evaluation at the quadrature points) ...
Definition: feVector.h:120
class that derived from abstract class feMat RHS computation of the weak formulation ...
Definition: feVector.h:16
A class to manage octants.
Definition: TreeNode.h:35
void readFromGhostEnd(T *vec, unsigned int dof=1)
Sync the ghost element exchange.
unsigned int end()
Returns if the current element has reached end or not.
void next()
: increment it to the next element.
virtual void elementalComputVec(const VECType *in, VECType *out, double *coords=NULL, double scale=1.0)=0
evalVec for the elemental vec
void getElementNodalValues(const T *in, T *eleVecOut, unsigned int eleID, unsigned int dof=1) const
computes the element nodal values using interpolation if needed.
void ghostedNodalToNodalVec(const T *gVec, T *&local, bool isAllocated=false, unsigned int dof=1) const
convert ghosted nodal vector to local vector (without ghosting)
void readFromGhostBegin(T *vec, unsigned int dof=1)
Initiate the ghost nodal value exchange.
void nodalVecToGhostedNodal(const T *in, T *&out, bool isAllocated=false, unsigned int dof=1) const
convert nodal local vector with ghosted buffer regions.
unsigned int getElementLocalBegin() const
return the begin location of element local
Definition: mesh.h:1030
double * m_uiEleCoords
Definition: feVector.h:30
void destroyVector(T *&local) const
deallocates the memory allocated for a vector
const std::vector< ot::TreeNode > & getAllElements() const
returns the pointer to All elements array.
Definition: mesh.h:1058
unsigned int getNumNodesPerElement() const
return the number of nodes per element.
Definition: mesh.h:1090
VECType * m_uiEleVecIn
element nodal vec in
Definition: feVector.h:24
feVector(ot::DA *da, unsigned int dof=1)
constructs an FEM stiffness matrix class.
Definition: feVector.h:99
unsigned int curr()
get the current elmenent in the iteration
const std::vector< unsigned int > & getE2NMapping() const
Definition: mesh.h:1073
void writeToGhostsEnd(T *vec, DA_FLAGS::WriteMode mode, unsigned int dof=1)
Sync accumilation across ghost elements.
void getElementalCoords(unsigned int eleID, double *coords) const
computes the elementCoordinates (based on the nodal placement)
Definition: oda.cpp:264
bool isActive() const
see if the current DA is active
Definition: oda.h:254
int createVector(T *&local, bool isElemental=false, bool isGhosted=false, unsigned int dof=1) const
Creates a ODA vector.
unsigned int m_uiDof
number of unknowns
Definition: feVector.h:21
void setVectorByScalar(T *local, const T *value, bool isElemental=false, bool isGhosted=false, unsigned int dof=1) const
initialize a variable vector to a function depends on spatial coords.
void writeToGhostsBegin(T *vec, unsigned int dof=1)
Initiate accumilation across ghost elements.
ot::DA * m_uiOctDA
: pointer to OCT DA
Definition: feVec.h:24
const ot::Mesh * getMesh() const
returns the mesh
Definition: oda.h:269
unsigned int getTotalNodalSz() const
returns the total nodal size (this includes the ghosted region as well.)
Definition: oda.h:245
void init()
initialize the loop counters.