1#include <dune/composites/Setup/parallelPartition.hh>
2#include <dune/composites/Setup/GridTransformation.hh>
3#include <dune/composites/Setup/dirichletBC.hh>
4#include <dune/composites/Driver/FEM/Serendipity/serendipityfem.hh>
6#include "../PostProcessing/computeStresses.hh"
7#include "../PostProcessing/plot_properties.hh"
8#include "localOperator/linearelasticity.hh"
14 template <
typename MODEL>
18 typedef Dune::PDELab::istl::VectorBackend<Dune::PDELab::istl::Blocking::none,1> Scalar_VectorBackend;
19 typedef Dune::PDELab::istl::VectorBackend<Dune::PDELab::istl::Blocking::fixed,3> VectorBackend;
20 typedef Dune::PDELab::istl::BCRSMatrixBackend<> MBE;
25 Dune::MPIHelper& helper;
31 void inline setElementOrder(
int val = 2){
35 void inline apply(MODEL& myModel){
36 if (myModel.setUp_Required ==
true){
38 myModel.setUpMaterials();
39 myModel.computeElasticTensors();
43 std::vector<double> times(3);
47 typedef Dune::YaspGrid<3,Dune::TensorProductCoordinates<double,3>> YGRID;
49 YGRID yaspgrid(myModel.coords,myModel.periodic,myModel.overlap,helper.getCommunicator(),(Dune::YLoadBalance<3>*)&yp);
50 int refinements = myModel.refineBaseGrid;
51 if(refinements > 0) yaspgrid.globalRefine(refinements);
52 typedef YGRID::LeafGridView YGV;
53 const YGV& ygv = yaspgrid.leafGridView();
55 if(helper.rank() == 0){
56 std::cout <<
"Number of elements per processor: " << ygv.size(0) << std::endl;
57 std::cout <<
"Number of nodes per processor: " << ygv.size(3) << std::endl;
66 GRID_TRAFO gTrafo(myModel, helper.rank());
68 typedef typename Dune::GeometryGrid<YGRID,GRID_TRAFO> GRID;
69 GRID grid(yaspgrid,gTrafo);
70 if(helper.rank() == 0)
71 std::cout <<
"Grid transformation complete" << std::endl;
74 typedef typename GRID::LeafGridView GV;
75 const GV& gv = grid.leafGridView();
77 if(helper.rank() == 0)
78 std::cout <<
"Grid view set up" << std::endl;
80 times[1] = watch.elapsed();
84 typedef Dune::PDELab::CompositeConstraintsParameters<BC,BC,BC> Constraints;
89 myModel.template computeTensorsOnGrid<GV,YGV>(gv,ygv);
93 InitialDisp u1(gv, myModel,0), u2(gv, myModel,1), u3(gv, myModel,2);
96 typedef Dune::PDELab::CompositeGridFunction<InitialDisp,InitialDisp,InitialDisp> InitialSolution;
97 InitialSolution initial_solution(u1,u2,u3);
100 typedef Dune::PDELab::OverlappingConformingDirichletConstraints CON;
103 times[2] = watch.elapsed();
107 const int element_order = 2;
108 const int dofel = 3 * 20;
109 const int non_zeros = 81;
111 if(helper.rank() == 0)
112 std::cout <<
"Piecewise quadratic serendipity elements" << std::endl;
117 typedef Dune::PDELab::GridFunctionSpace<GV, FEM, CON, Scalar_VectorBackend> SCALAR_GFS;
118 SCALAR_GFS dispU1(gv,fem,con); dispU1.name(
"U1");
119 SCALAR_GFS dispU2(gv,fem,con); dispU2.name(
"U2");
120 SCALAR_GFS dispU3(gv,fem,con); dispU3.name(
"U3");
123 typedef Dune::PDELab::CompositeGridFunctionSpace <VectorBackend,Dune::PDELab::EntityBlockedOrderingTag, SCALAR_GFS, SCALAR_GFS, SCALAR_GFS> GFS;
124 const GFS gfs(dispU1, dispU2, dispU3);
126 typedef typename GFS::template ConstraintsContainer<RF>::Type C;
132 BC U1_cc(gv,myModel,0), U2_cc(gv,myModel,1), U3_cc(gv,myModel,2);
133 Constraints constraints(U1_cc,U2_cc,U3_cc);
135 Dune::PDELab::constraints(constraints,gfs,cg);
140 typedef Dune::PDELab::linearelasticity<GV, MODEL, dofel> LOP;
141 LOP lop(gv, myModel);
143 typedef Dune::PDELab::GridOperator<GFS,GFS,LOP,MBE,RF,RF,RF,C,C> GO;
144 GO go(gfs,cg,gfs,cg,lop,mbe);
147 typedef Dune::PDELab::Backend::Vector<GFS,double> V;
149 Dune::PDELab::interpolate(initial_solution,gfs,u);
152 Dune::PDELab::set_shifted_dofs(cg,0.0,u);
153 myModel.template solve<GO,V,GFS,C,Constraints,MBE,LOP>(go,u,gfs,cg,constraints,mbe,lop);
156 Dune::SubsamplingVTKWriter<GV> vtkwriter(gv,0);
157 Dune::PDELab::addSolutionToVTKWriter(vtkwriter,gfs,u);
158 vtkwriter.write(myModel.vtk_displacement_output,Dune::VTK::appendedraw);
161 calculateStresses<MODEL,V,GV,GFS,MBE>(myModel,u,gv,gfs,mbe);
163 plotProperties<MODEL,V,GV,GFS,MBE>(myModel,gv,gfs,mbe);
165 myModel.template postprocess<GO,V,GFS,C,MBE,GV>(go,u,gfs,cg,gv,mbe);
Define Scalar Dirichlet Boundary Conditions.
Definition: dirichletBC.hh:14
Partition yaspgrid for parallelism.
Definition: parallelPartition.hh:12
linear static driver
Definition: linearStaticDriver.hh:15
Definition: serendipityfem.hh:20