1#ifndef COMPUTE_STRESSES_HH
2#define COMPUTE_STRESSES_HH
6template<
class MODEL,
typename V,
typename GV1,
typename GFS,
typename MBE>
7void calculateStresses(MODEL& model, V& x0,
const GV1& gv1,
const GFS& gfs, MBE& mbe,
int dofel = 60){
9 using Dune::PDELab::Backend::native;
11 typedef Dune::PDELab::istl::VectorBackend<Dune::PDELab::istl::Blocking::none,1> Scalar_VectorBackend;
13 std::string vtk_output = config.get<std::string>(
"ModelName",
"TestModel");
16 using GV = Dune::PDELab::AllEntitySet<GV1>;
21 typedef typename GV::Grid::ctype e_ctype;
22 typedef Dune::PDELab::QkDGLocalFiniteElementMap<e_ctype,double,0,3> FEM_stress;
23 FEM_stress fem_stress;
25 typedef Dune::PDELab::GridFunctionSpace<GV, FEM_stress, Dune::PDELab::NoConstraints, Scalar_VectorBackend> SCALAR_P1GFS;
26 SCALAR_P1GFS p1gfs_00(gv,fem_stress); p1gfs_00.name(
"stress00"); SCALAR_P1GFS p1gfs_11(gv,fem_stress); p1gfs_11.name(
"stress11");
27 SCALAR_P1GFS p1gfs_22(gv,fem_stress); p1gfs_22.name(
"stress22"); SCALAR_P1GFS p1gfs_12(gv,fem_stress); p1gfs_12.name(
"stress12");
28 SCALAR_P1GFS p1gfs_02(gv,fem_stress); p1gfs_02.name(
"stress02"); SCALAR_P1GFS p1gfs_01(gv,fem_stress); p1gfs_01.name(
"stress01");
30 typedef Dune::PDELab::istl::VectorBackend<Dune::PDELab::istl::Blocking::fixed,6> VectorBackend;
31 typedef Dune::PDELab::CompositeGridFunctionSpace <VectorBackend,Dune::PDELab::EntityBlockedOrderingTag,
32 SCALAR_P1GFS, SCALAR_P1GFS, SCALAR_P1GFS, SCALAR_P1GFS, SCALAR_P1GFS, SCALAR_P1GFS> P1GFS;
34 P1GFS p1gfs(p1gfs_00,p1gfs_11,p1gfs_22,p1gfs_12,p1gfs_02,p1gfs_01);
37 Dune::PDELab::getStress<GV,MODEL,60> lopStress(gv,model);
39 typedef Dune::PDELab::EmptyTransformation NoTrafo;
40 typedef Dune::PDELab::GridOperator<GFS,P1GFS,Dune::PDELab::getStress<GV,MODEL,60>,MBE,RF,RF,RF,NoTrafo,NoTrafo> GOStress;
41 GOStress goStress(gfs,p1gfs,lopStress,mbe);
43 typedef typename GOStress::Traits::Range V1;
45 goStress.residual(x0,stress);
48 model.sizeStressVector(native(stress).size());
49 for (
unsigned int i = 0; i < native(stress).size(); i++){
50 model.setStress(i,native(stress)[i]);
54 if(model.stress_Plot){
55 Dune::SubsamplingVTKWriter<GV1> vtkwriter(gv1,0);
56 Dune::PDELab::addSolutionToVTKWriter(vtkwriter,p1gfs,stress);
57 vtkwriter.write(model.vtk_stress_output,Dune::VTK::appendedraw);