Skip to content
Snippets Groups Projects
Commit dd1c1148 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

More structure

parent d91b9f19
No related branches found
No related tags found
No related merge requests found
...@@ -251,12 +251,18 @@ int main(int argc, char *argv[]) { ...@@ -251,12 +251,18 @@ int main(int argc, char *argv[]) {
MatrixType massMatrix; MatrixType massMatrix;
VectorType gravityFunctional; VectorType gravityFunctional;
{ {
// Assemble mass matrix and compute density double const gravity = 9.81;
double const density = parset.get<double>("body.density");
{ // Assemble mass matrix
MassAssembler<GridType, P1Basis::LocalFiniteElement, MassAssembler<GridType, P1Basis::LocalFiniteElement,
P1Basis::LocalFiniteElement> const localMass; P1Basis::LocalFiniteElement> const localMass;
OperatorAssembler<P1Basis, P1Basis>(p1Basis, p1Basis) OperatorAssembler<P1Basis, P1Basis>(p1Basis, p1Basis)
.assemble(localMass, massMatrix); .assemble(localMass, massMatrix);
massMatrix *= density;
}
{ // Compute normal stress
double volume = 1.0; double volume = 1.0;
for (int i = 0; i < dim; ++i) for (int i = 0; i < dim; ++i)
volume *= (upperRight[i] - lowerLeft[i]); volume *= (upperRight[i] - lowerLeft[i]);
...@@ -266,17 +272,13 @@ int main(int argc, char *argv[]) { ...@@ -266,17 +272,13 @@ int main(int argc, char *argv[]) {
if (i != 1) if (i != 1)
area *= (upperRight[i] - lowerLeft[i]); area *= (upperRight[i] - lowerLeft[i]);
double const gravity = 9.81;
double const density = parset.get<double>("body.density");
// volume * gravity * density / area = normal stress // volume * gravity * density / area = normal stress
// V * g * rho / A = sigma_n // V * g * rho / A = sigma_n
// m^d * N/kg * kg/m^d / m^(d-1) = N/m^(d-1) // m^d * N/kg * kg/m^d / m^(d-1) = N/m^(d-1)
normalStress = volume * gravity * density / area; normalStress = volume * gravity * density / area;
}
massMatrix *= density; { // Compute gravitational body force
// Compute gravitational body force
SmallVector weightedGravitationalDirection(0); SmallVector weightedGravitationalDirection(0);
weightedGravitationalDirection[1] = -density * gravity; weightedGravitationalDirection[1] = -density * gravity;
ConstantFunction<SmallVector, SmallVector> const gravityFunction( ConstantFunction<SmallVector, SmallVector> const gravityFunction(
...@@ -286,6 +288,7 @@ int main(int argc, char *argv[]) { ...@@ -286,6 +288,7 @@ int main(int argc, char *argv[]) {
FunctionalAssembler<P1Basis>(p1Basis) FunctionalAssembler<P1Basis>(p1Basis)
.assemble(gravityFunctionalAssembler, gravityFunctional, true); .assemble(gravityFunctionalAssembler, gravityFunctional, true);
} }
}
// Assemble elastic force on the body // Assemble elastic force on the body
MatrixType stiffnessMatrix; MatrixType stiffnessMatrix;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment