Skip to content
Snippets Groups Projects
Commit 9f703bc7 authored by webmanue's avatar webmanue
Browse files

add framework for volume

parent 9eb3570a
No related branches found
No related tags found
No related merge requests found
......@@ -46,8 +46,10 @@ add_library(${PROJECT_NAME}-elements
integrator/IntegrateTrait.cc
integrator/IntegratorBase.cc
integrator/IsoparametricIntegrator.cc
integrator/VolumeTrait.cc
integrator/integrate.cc
integrator/integrate_shape.cc
integrator/volume.cc
materialmodels/AutomaticStressTrait.cc
materialmodels/AutomaticTangentMatrixTrait.cc
materialmodels/ComputeEnergyTrait.cc
......
......@@ -19,6 +19,7 @@
#include "ae108/elements/integrator/IntegrateShapeTrait.h"
#include "ae108/elements/integrator/IntegrateTrait.h"
#include "ae108/elements/integrator/IntegratorBase.h"
#include "ae108/elements/integrator/VolumeTrait.h"
#include "ae108/elements/quadrature/integrate.h"
#include "ae108/elements/tensor/Tensor.h"
#include "ae108/elements/tensor/as_matrix_of_rows.h"
......@@ -124,6 +125,17 @@ struct IntegrateShapeTrait<
}
};
template <class Shape_, class Quadrature_, class ValueType_, class RealType_>
struct VolumeTrait<
IsoparametricIntegrator<Shape_, Quadrature_, ValueType_, RealType_>> {
template <class Integrator>
auto operator()(const Integrator &integrator) const noexcept {
return quadrature::integrate<Quadrature_>(
[](auto &&, auto &&, const auto &post) { return post; },
typename Integrator::real_type{0.}, integrator.post());
}
};
} // namespace integrator
} // namespace elements
} // namespace ae108
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
namespace ae108 {
namespace elements {
namespace integrator {
template <class Integrator> struct VolumeTrait;
} // namespace integrator
} // namespace elements
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "ae108/elements/integrator/VolumeTrait.h"
namespace ae108 {
namespace elements {
namespace integrator {
/**
* @brief Integrates the constant function 1.
*/
template <class Integrator>
typename Integrator::real_type volume(const Integrator &integrator) noexcept {
return VolumeTrait<Integrator>().template operator()(integrator);
}
} // namespace integrator
} // namespace elements
} // namespace ae108
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "ae108/elements/integrator/VolumeTrait.h"
\ No newline at end of file
// © 2022 ETH Zurich, Mechanics and Materials Lab
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "ae108/elements/integrator/volume.h"
\ No newline at end of file
......@@ -16,6 +16,7 @@
#include "ae108/elements/integrator/IsoparametricIntegrator.h"
#include "ae108/elements/integrator/integrate.h"
#include "ae108/elements/integrator/integrate_shape.h"
#include "ae108/elements/integrator/volume.h"
#include "ae108/elements/quadrature/Quadrature.h"
#include "ae108/elements/shape/Seg2.h"
#include <gmock/gmock.h>
......@@ -56,8 +57,8 @@ TEST_F(IsoperimetricIntegrator_Test, post_transform_is_correct) {
EXPECT_THAT(post, ElementsAre(DoubleEq(.5)));
}
TEST_F(IsoperimetricIntegrator_Test, computing_volume_works) {
const auto result = integrate<Integrator>(
TEST_F(IsoperimetricIntegrator_Test, computing_volume_via_integration_works) {
const auto result = integrate(
integrator,
[](const Integrator::size_type &, const Integrator::Point<1> &,
const Integrator::PreTransform &) { return 1.; },
......@@ -66,9 +67,14 @@ TEST_F(IsoperimetricIntegrator_Test, computing_volume_works) {
EXPECT_THAT(result, DoubleEq(1.));
}
TEST_F(IsoperimetricIntegrator_Test, computing_volume_works) {
const auto result = volume(integrator);
EXPECT_THAT(result, DoubleEq(1.));
}
TEST_F(IsoperimetricIntegrator_Test, integrating_shape_works) {
const auto factor = std::sqrt(2.);
const auto result = integrate_shape<Integrator>(
const auto result = integrate_shape(
integrator,
[factor](auto &&, const auto &point) {
return point[0] + factor * point[1];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment