Skip to content
Permalink
Browse files

Merge branch 'additional_diffops_bnd' into 'master'

Additional diffops bnd

See merge request jschoeberl/ngsolve!278
  • Loading branch information
JSchoeberl committed Dec 15, 2017
2 parents 419f36b + 2dbe3bc commit 14fa899c587d1639627c396236f1cc229d160471
Showing with 81 additions and 28 deletions.
  1. +66 −25 comp/facetsurffespace.cpp
  2. +15 −3 comp/python_comp.cpp
@@ -88,6 +88,29 @@ namespace ngcomp
virtual string Name () const { return "FacetSurface-Mass"; }
};

/// Identity on boundary
template <int D, typename FEL = ScalarFiniteElement<D-2> >
class DiffOpIdFacetSurfaceBoundary : public DiffOp<DiffOpIdFacetSurfaceBoundary<D, FEL> >
{
public:
enum { DIM = 1 };
enum { DIM_SPACE = D };
enum { DIM_ELEMENT = D-2 };
enum { DIM_DMAT = 1 };
enum { DIFFORDER = 0 };

static const FEL & Cast (const FiniteElement & fel)
{ return static_cast<const FEL&> (fel); }

template <typename AFEL, typename MIP, typename MAT>
static void GenerateMatrix (const AFEL & fel, const MIP & mip,
MAT & mat, LocalHeap & lh)
{
Cast(fel).CalcShape (mip.IP(), mat.Row(0));
}

};




@@ -164,6 +187,8 @@ namespace ngcomp
{
evaluator[VOL] = make_shared<T_DifferentialOperator<DiffOpIdFacet<3>>>();
evaluator[BND] = make_shared<T_DifferentialOperator<DiffOpIdFacetSurface<3>>>();
evaluator[BBND] = make_shared<T_DifferentialOperator<DiffOpIdFacetSurfaceBoundary<3>>>();

integrator[BND] = make_shared<RobinIntegrator<3>> (one);
}

@@ -222,6 +247,8 @@ namespace ngcomp
// ------------------------------------------------------------------------
FiniteElement & FacetSurfaceFESpace :: GetFE (ElementId ei, Allocator & lh) const
{
auto vnums = ma->GetElVertices(ei);

switch(ei.VB())
{
case VOL:
@@ -233,33 +260,47 @@ namespace ngcomp
{
FacetFE<ET_TRIG>* fe = 0;

switch (ma->GetElType(ei))
{
case ET_TRIG: fe = new (lh) FacetFE<ET_TRIG> (); break;
default:
throw Exception (string("FacetSurfaceFESpace::GetFE: unsupported element ")+
ElementTopology::GetElementName(ma->GetElType(ei)));
}


auto vnums = ma->GetElVertices(ei);
switch (ma->GetElType(ei))
{
case ET_TRIG:
{
fe -> SetVertexNumbers (vnums);
fe -> SetOrder (order);
fe -> ComputeNDof();
return *fe;
break;
}
default:
break;
}
return *fe;
switch (ma->GetElType(ei))
{
case ET_TRIG: fe = new (lh) FacetFE<ET_TRIG> (); break;
default:
throw Exception (string("FacetSurfaceFESpace::GetFE: unsupported element ")+
ElementTopology::GetElementName(ma->GetElType(ei)));
}

switch (ma->GetElType(ei))
{
case ET_TRIG:
{
fe -> SetVertexNumbers (vnums);
fe -> SetOrder (order);
fe -> ComputeNDof();
return *fe;
break;
}
default:
break;
}
return *fe;
}
case BBND:
throw Exception("No BBND GetFE implemented for FacetSurfaceFESpace");
{
DGFiniteElement<1> * fe1d = 0;

switch (ma->GetElType(ei))
{
case ET_SEGM: fe1d = new (lh) L2HighOrderFE<ET_SEGM> (); break;
default:
throw Exception (string("FacetSurfaceFESpace::GetFE: unsupported element ")+
ElementTopology::GetElementName(ma->GetElType(ei)));
}

fe1d -> SetVertexNumbers (vnums);
fe1d -> SetOrder (order);
fe1d -> ComputeNDof();
return *fe1d;
break;
}
case BBBND:
throw Exception("No BBBND GetFE implemented for FacetSurfaceFESpace");
}
@@ -2128,18 +2128,30 @@ used_idnrs : list of int = None
})

.def("Operator",
[](shared_ptr<GF> self, string name) -> py::object // shared_ptr<CoefficientFunction>
[](shared_ptr<GF> self, string name, VorB vb) -> py::object // shared_ptr<CoefficientFunction>
{
if (self->GetFESpace()->GetAdditionalEvaluators().Used(name))
{
auto diffop = self->GetFESpace()->GetAdditionalEvaluators()[name];
// cout << "diffop is " << typeid(*diffop).name() << endl;
auto coef = make_shared<GridFunctionCoefficientFunction> (self, diffop);
shared_ptr<GridFunctionCoefficientFunction> coef;
switch(vb)
{
case VOL:
coef = make_shared<GridFunctionCoefficientFunction> (self, diffop);
break;
case BND:
coef = make_shared<GridFunctionCoefficientFunction> (self, nullptr,diffop);
break;
case BBND:
coef = make_shared<GridFunctionCoefficientFunction> (self, nullptr,nullptr,diffop);
break;
}
coef->SetDimensions(diffop->Dimensions());
return py::cast(shared_ptr<CoefficientFunction>(coef));
}
return py::none(); // shared_ptr<CoefficientFunction>();
})
}, py::arg("name"), py::arg("VB")=VOL)


.def_property_readonly("derivname",

0 comments on commit 14fa899

Please sign in to comment.
You can’t perform that action at this time.