25 #ifndef GRINS_DISTANCE_FUNCTION_H
26 #define GRINS_DISTANCE_FUNCTION_H
32 #include "libmesh/libmesh_base.h"
33 #include "libmesh/libmesh_common.h"
34 #include "libmesh/auto_ptr.h"
35 #include "libmesh/dense_vector.h"
36 #include "libmesh/dense_matrix.h"
37 #include "libmesh/fe_base.h"
38 #include "libmesh/system.h"
39 #include "libmesh/elem.h"
43 class EquationSystems;
60 DistanceFunction (libMesh::EquationSystems &es_in,
const libMesh::UnstructuredMesh &bm_in);
86 libMesh::UniquePtr< libMesh::DenseVector<libMesh::Real> >
interpolate (
const libMesh::Elem* elem,
const std::vector<libMesh::Point>& qts)
const;
132 void operator()(
const libMesh::DenseVector<libMesh::Real> &U,
133 const libMesh::DenseVector<libMesh::Real> & F0,
135 libMesh::DenseMatrix<libMesh::Real> &dFdU)
141 dFdU.resize(U.size(),U.size());
144 for (
unsigned int j=0; j<U.size(); j++)
154 pert = 4.e-8*(std::max (std::abs(U(j)), 1.e-3));
159 invpert = 1./(
Up(j) - U(j));
167 for (
unsigned int i=0; i<U.size(); i++)
168 dFdU(i,j) = (
Fp(i) - F0(i))*invpert;
175 libMesh::DenseVector<libMesh::Real>
Up,
Fp,
Um,
Fm;
201 libmesh_assert(
_belem.type()==libMesh::QUAD4);
208 void operator()(
const libMesh::DenseVector<libMesh::Real> &U,
209 libMesh::DenseVector<libMesh::Real> &F)
212 libmesh_assert(U.size()==
_dim-1);
213 libmesh_assert(F.size()==
_dim-1);
215 libMesh::DenseVector<libMesh::Real> xx(
_dim);
218 libMesh::DenseMatrix<libMesh::Real> xx_U(
_dim,
_dim-1);
221 std::vector<libMesh::Point> xi(1);
227 const std::vector<std::vector<libMesh::Real> > &basis =
fe->get_phi();
228 const std::vector<std::vector<libMesh::RealGradient> > &dbasis =
fe->get_dphi();
234 for (
unsigned int inode=0; inode<
_belem.n_nodes(); ++inode)
235 for (
unsigned int idim=0; idim<
_dim; ++idim)
237 xx(idim) +=
_belem.point(inode)(idim) * basis[inode][0];
239 for (
unsigned int jdim=0; jdim<_dim-1; ++jdim)
240 xx_U(idim, jdim) +=
_belem.point(inode)(idim) * dbasis[inode][0](jdim);
246 for (
unsigned int ires=0; ires<_dim-1; ++ires)
247 for (
unsigned int idim=0; idim<
_dim; ++idim)
248 F(ires) += ( xx(idim) -
_p(idim) ) * xx_U(idim, ires);
258 const libMesh::Point&
_p;
260 libMesh::UniquePtr<libMesh::FEBase>
_fe;
264 libMesh::DenseVector<libMesh::Real>
Up,
Fp,
Um,
Fm;
269 #endif // __distance_function_h__
const libMesh::Point & _p
~ComputeDistanceResidual()
const libMesh::Elem & _belem
libMesh::UniquePtr< libMesh::FEBase > _dist_fe
libMesh::DenseVector< libMesh::Real > Up
libMesh::DenseVector< libMesh::Real > Um
libMesh::EquationSystems & _equation_systems
DistanceFunction(libMesh::EquationSystems &es_in, const libMesh::UnstructuredMesh &bm_in)
libMesh::DenseVector< libMesh::Real > Fp
void operator()(const libMesh::DenseVector< libMesh::Real > &U, const libMesh::DenseVector< libMesh::Real > &F0, f &F, libMesh::DenseMatrix< libMesh::Real > &dFdU)
ComputeDistanceResidual(const libMesh::Elem *belem, const libMesh::Point *point)
libMesh::UniquePtr< libMesh::DenseVector< libMesh::Real > > interpolate(const libMesh::Elem *elem, const std::vector< libMesh::Point > &qts) const
libMesh::UniquePtr< libMesh::FEBase > _fe
libMesh::DenseVector< libMesh::Real > Fm
ComputeDistanceJacobian()
libMesh::DenseVector< libMesh::Real > Fp
libMesh::DenseVector< libMesh::Real > Um
virtual void initialize()
~ComputeDistanceJacobian()
libMesh::DenseVector< libMesh::Real > Fm
libMesh::Real node_to_boundary(const libMesh::Node *node)
void operator()(const libMesh::DenseVector< libMesh::Real > &U, libMesh::DenseVector< libMesh::Real > &F)
const libMesh::UnstructuredMesh & _boundary_mesh
libMesh::DenseVector< libMesh::Real > Up