MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / DiffShape

Method DiffShape

fem/integratorcf.hpp:143–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 }
142
143 shared_ptr<SumOfIntegrals>
144 DiffShape (shared_ptr<CoefficientFunction> dir) const
145 {
146 auto deriv = make_shared<SumOfIntegrals>();
147 auto grad = dir->Operator("grad");
148 if (!grad)
149 throw Exception("In SumOfIntegrals::DiffShape: dir does not have a grad operator");
150 auto divdir = TraceCF(grad);
151 auto sgrad = dynamic_pointer_cast<ProxyFunction>(grad)->Trace();
152 auto sdivdir = TraceCF(sgrad);
153
154 auto tang = TangentialVectorCF(dir->Dimension(), false) -> Reshape(dir->Dimension(), 1);
155 auto bsdivdir = InnerProduct(sgrad*tang,tang);
156
157 DiffShapeCF shape;
158 //cout << "should add Eulerian here" << endl;
159
160 for (auto & icf : icfs)
161 {
162 switch (icf->dx.vb)
163 {
164 case VOL:
165 if (icf->dx.element_vb == VOL)
166 deriv->icfs += icf->CreateSameIntegralType ( icf->cf->Diff(&shape, dir) + divdir*icf->cf);
167 else
168 throw Exception("In DiffShape: for vb=VOL only element_vb=VOL implemented!");
169 break;
170 case BND:
171 if (icf->dx.element_vb == VOL)
172 deriv->icfs += icf->CreateSameIntegralType ( icf->cf->Diff(&shape, dir) + sdivdir*icf->cf);
173 else if (icf->dx.element_vb == BND && dir->Dimension() == 3)
174 deriv->icfs += icf->CreateSameIntegralType ( icf->cf->Diff(&shape, dir) + bsdivdir*icf->cf);
175 else if (icf->dx.element_vb == BND && dir->Dimension() == 2)
176 deriv->icfs += icf->CreateSameIntegralType ( icf->cf->Diff(&shape, dir));
177 else
178 throw Exception("In DiffShape: for vb=BND something went wrong!");
179 break;
180 default:
181 throw Exception("In DiffShape: for vb="+ToString(icf->dx.vb)+" and element_vb="+ToString(icf->dx.element_vb) + " not implemented!");
182 }
183 }
184 return deriv;
185 }
186
187
188 shared_ptr<SumOfIntegrals>

Callers

nothing calls this directly

Calls 8

TraceCFFunction · 0.85
TangentialVectorCFFunction · 0.85
ToStringFunction · 0.85
InnerProductFunction · 0.70
OperatorMethod · 0.45
DimensionMethod · 0.45
DiffMethod · 0.45

Tested by

no test coverage detected