Skip to content

Commit 3b8d823

Browse files
committed
matfree tangentialfacet - tangentialcomponent
1 parent dbeb113 commit 3b8d823

File tree

2 files changed

+127
-1
lines changed

2 files changed

+127
-1
lines changed

comp/hdivhofespace.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ namespace ngcomp
4040
enum { DIFFORDER = 0 };
4141
// enum { DIM_STRESS = D };
4242

43-
static Array<int> GetDimensions() { return Array<int> ({1}); }
43+
// static Array<int> GetDimensions() { return Array<int> ({1}); }
44+
static Array<int> GetDimensions() { return Array<int>(0); }
4445

4546
/*
4647
template <typename FEL,typename SIP>

comp/tangentialfacetfespace.cpp

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,134 @@
99
#include "../fem/tangentialfacetfe.hpp"
1010
#include "../fem/hcurllofe.hpp"
1111
#include <../fem/hcurl_equations.hpp>
12+
#include <../fem/diffop_impl.hpp>
1213

1314

1415
namespace ngcomp
1516
{
1617

18+
19+
20+
template<int D>
21+
class DiffOpTangentialComponentHCurl: public DiffOp<DiffOpTangentialComponentHCurl<D> >
22+
{
23+
public:
24+
enum { DIM = 1 };
25+
enum { DIM_SPACE = D };
26+
enum { DIM_ELEMENT = D };
27+
enum { DIM_DMAT = D };
28+
enum { DIFFORDER = 0 };
29+
30+
static Array<int> GetDimensions() { return Array<int> ({D}); }
31+
32+
/*
33+
template <typename FEL,typename SIP>
34+
static void GenerateMatrix(const FEL & bfel,const SIP & mip,
35+
SliceMatrix<double,ColMajor> mat,LocalHeap & lh)
36+
{
37+
const HDivDivFiniteElement<D> & fel =
38+
dynamic_cast<const HDivDivFiniteElement<D>&> (bfel);
39+
fel.CalcMappedShape_Matrix (mip,Trans(mat));
40+
}
41+
*/
42+
43+
template <typename FEL,typename SIP,typename MAT>
44+
static void GenerateMatrix(const FEL & bfel,const SIP & sip,
45+
MAT && mat,LocalHeap & lh)
46+
{
47+
HeapReset hr(lh);
48+
auto & fel = dynamic_cast<const HCurlFiniteElement<D>&> (bfel);
49+
50+
int nd = fel.GetNDof();
51+
FlatMatrix<> shape(nd,D,lh);
52+
53+
Vec<D> n = sip.GetNV();
54+
fel.CalcMappedShape(sip,shape);
55+
Mat<D,D> proj = Id<D>(); // - OuterProduct(n,n);
56+
for (int i = 0; i < D; i++)
57+
for (int j = 0; j < D; j++)
58+
proj(i,j) -= n(i)*n(j);
59+
mat = proj*Trans(shape);
60+
}
61+
62+
63+
static int DimRef() { return D; }
64+
65+
template <typename IP, typename MAT>
66+
static void GenerateMatrixRef (const FiniteElement & fel, const IP & ip,
67+
MAT && mat, LocalHeap & lh)
68+
{
69+
static_cast<const BaseHCurlFiniteElement&> (fel).CalcShape (ip, Trans(mat));
70+
}
71+
72+
template <typename MIP, typename MAT>
73+
static void CalcTransformationMatrix (const MIP & bmip,
74+
MAT & mat, LocalHeap & lh)
75+
{
76+
auto & mip = static_cast<const MappedIntegrationPoint<D,D>&>(bmip);
77+
Vec<D> n = mip.GetNV();
78+
Mat<D,D> proj = Id<D>(); // - OuterProduct(n,n);
79+
for (int i = 0; i < D; i++)
80+
for (int j = 0; j < D; j++)
81+
proj(i,j) -= n(i)*n(j);
82+
83+
mat = proj * Trans(mip.GetJacobianInverse());
84+
}
85+
86+
87+
88+
89+
#ifdef NONE
90+
static void GenerateMatrixSIMDIR (const FiniteElement & bfel,
91+
const SIMD_BaseMappedIntegrationRule & bmir,
92+
BareSliceMatrix<SIMD<double>> mat)
93+
{
94+
// static Timer t("HDivDivFE - DiffOpNormalComponent", NoTracing);
95+
// RegionTracer regtr(TaskManager::GetThreadId(), t);
96+
97+
auto & fel = static_cast<const HDivFiniteElement<D>&> (bfel);
98+
fel.CalcMappedNormalShape (bmir, mat);
99+
/*
100+
auto & mir = static_cast<const SIMD_MappedIntegrationRule<D,D> &> (bmir);
101+
LocalHeapMem<100000> lh("normalcomp");
102+
auto & fel = dynamic_cast<const HDivFiniteElement<D>&> (bfel);
103+
int nd = fel.GetNDof();
104+
FlatMatrix<SIMD<double>> shape(nd*D, mir.Size(), lh);
105+
fel.CalcMappedShape (mir, shape);
106+
for (size_t i = 0; i < mir.Size(); i++)
107+
{
108+
auto nv = mir[i].GetNV();
109+
for (size_t j = 0; j < nd; j++)
110+
{
111+
SIMD<double> sum = 0.0;
112+
for (size_t k = 0; k < D; k++)
113+
sum += shape(j*D+k, i) * nv(k);
114+
mat(j, i) = sum;
115+
}
116+
}
117+
*/
118+
}
119+
#endif
120+
/*
121+
using DiffOp<DiffOpIdHDivDiv<D> >::ApplySIMDIR;
122+
static void ApplySIMDIR (const FiniteElement & bfel, const SIMD_BaseMappedIntegrationRule & mir,
123+
BareSliceVector<double> x, BareSliceMatrix<SIMD<double>> y)
124+
{
125+
dynamic_cast<const HDivDivFiniteElement<D>&> (bfel).Evaluate_Matrix (mir, x, y);
126+
}
127+
128+
using DiffOp<DiffOpIdHDivDiv<D> >::AddTransSIMDIR;
129+
static void AddTransSIMDIR (const FiniteElement & bfel, const SIMD_BaseMappedIntegrationRule & mir,
130+
BareSliceMatrix<SIMD<double>> y, BareSliceVector<double> x)
131+
{
132+
dynamic_cast<const HDivDivFiniteElement<D>&> (bfel).AddTrans_Matrix (mir, y, x);
133+
}
134+
*/
135+
};
136+
137+
138+
139+
17140
TangentialFacetFESpace :: TangentialFacetFESpace (shared_ptr<MeshAccess> ama, const Flags & flags,
18141
bool parseflags )
19142
: FESpace(ama, flags )
@@ -108,9 +231,11 @@ namespace ngcomp
108231
break;
109232
case 2:
110233
additional_evaluators.Set ("dual", make_shared<T_DifferentialOperator<DiffOpHCurlDual<2>>> ());
234+
additional_evaluators.Set ("tangentialcomponent", make_shared<T_DifferentialOperator<DiffOpTangentialComponentHCurl<2>>> ());
111235
break;
112236
case 3:
113237
additional_evaluators.Set ("dual", make_shared<T_DifferentialOperator<DiffOpHCurlDual<3>>> ());
238+
additional_evaluators.Set ("tangentialcomponent", make_shared<T_DifferentialOperator<DiffOpTangentialComponentHCurl<3>>> ());
114239
break;
115240
default:
116241
break;

0 commit comments

Comments
 (0)