Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ if(OpenMP_CXX_FOUND)
message(STATUS "Found OpenMP")
endif()

if(OpenMP_CXX_FOUND)
message(STATUS "Found OpenMP: ${OpenMP_CXX_FLAGS}")

add_library(cfem_openmp_interface INTERFACE)

target_link_libraries(cfem_openmp_interface INTERFACE OpenMP::OpenMP_CXX)

target_compile_definitions(cfem_openmp_interface INTERFACE WITH_OPENMP)
endif()

# ------------------------------------------------------------
# Modular Libraries & Applications
# ------------------------------------------------------------
Expand All @@ -156,4 +166,4 @@ if(BUILD_TESTING)

include(GoogleTest)
add_subdirectory(tests)
endif()
endif()
2 changes: 1 addition & 1 deletion apps/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static char help[] = "CFEM Example: Field projection on a quadratic mesh.\n\n";

int main(int argc, char **argv)
{
//omp_set_num_threads(1);
// omp_set_num_threads(4);
Environment::initialize(argc, argv, help);
{
#define CFEM_USE_DYNAMIC_SPACE_CACHE
Expand Down
3 changes: 2 additions & 1 deletion libs/expressions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ target_link_libraries(cfem_expressions
${MPFR_LIB}
${MPC_LIB}
# ${LLVM_SYSTEM_LIBS}
)
cfem_openmp_interface
)
8 changes: 4 additions & 4 deletions libs/expressions/include/CfemExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace cfem::sym
g->evaluate(cellId, xi, out, ctx);
return;
}
CFEM_ERROR << "Gradient evaluation failed.";
CFEM_THROW("Gradient evaluation failed.");
}

virtual void prepare() const {};
Expand Down Expand Up @@ -128,7 +128,7 @@ namespace cfem::sym
m_gradient = createGradient();
}
if ( !m_gradient ){
CFEM_ERROR << "Could not differentiate expression: " << toString();
CFEM_THROW("Could not differentiate expression: " << toString());
}
return m_gradient;
}
Expand All @@ -138,7 +138,7 @@ namespace cfem::sym
m_timeDeriv = createTimeDerivative();
}
if ( !m_timeDeriv ){
CFEM_ERROR << "Could not differentiate expression: " << toString();
CFEM_THROW("Could not differentiate expression: " << toString());
}
return m_timeDeriv;
}
Expand Down Expand Up @@ -180,7 +180,7 @@ namespace cfem::sym {

// Otherwise, check if it's already used by someone else to avoid collisions
if (active_variables.contains(name)) {
CFEM_ERROR << "Variable name '" << name << "' is already in use.";
CFEM_THROW("Variable name '" << name << "' is already in use.");
}
active_variables.insert(name);
}
Expand Down
6 changes: 3 additions & 3 deletions libs/expressions/include/DivergenceExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace cfem::sym
}

std::shared_ptr<const CfemExpression> createGradient() const override {
CFEM_ERROR << "The gradient of a divergence node requires a dedicated GradExpression fallback.";
CFEM_THROW("The gradient of a divergence node requires a dedicated GradExpression fallback.");
return nullptr;
}

Expand All @@ -61,13 +61,13 @@ namespace cfem::sym
m_dimIn = m_expr->getDimension();

if (m_dimIn == 1) {
CFEM_ERROR << "Divergence cannot be applied to a scalar field: " << m_expr->toString();
CFEM_THROW("Divergence cannot be applied to a scalar field: " << m_expr->toString());
} else if (m_dimIn == 3) {
m_dimOut = 1; // Vector -> Scalar
} else if (m_dimIn == 9) {
m_dimOut = 3; // Tensor -> Vector
} else {
CFEM_ERROR << "Unsupported dimension for divergence: " << m_dimIn;
CFEM_THROW("Unsupported dimension for divergence: " << m_dimIn);
}

m_dx = m_expr->diff(0);
Expand Down
4 changes: 2 additions & 2 deletions libs/expressions/include/GradExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace cfem::sym
std::shared_ptr<const CfemExpression> m_expr;

std::shared_ptr<const CfemExpression> createGradient() const override{
CFEM_ERROR << "GradExpression does not yet support grad(). Cannot compute spatial derivatives for GradExpression.";
CFEM_THROW("GradExpression does not yet support grad(). Cannot compute spatial derivatives for GradExpression.");
return nullptr;
}
std::shared_ptr<const CfemExpression> createTimeDerivative() const override{
Expand All @@ -50,7 +50,7 @@ namespace cfem::sym
explicit GradExpression(std::shared_ptr<const CfemExpression> expr) : m_expr(std::move(expr)) {
if (auto lambda = std::dynamic_pointer_cast<const LambdaExpressionBase>(expr) ){
if (!(lambda->grad()))
CFEM_ERROR << "LambdaExpressions are currentely not supported by the automatic differentation.";
CFEM_THROW("LambdaExpressions are currentely not supported by the automatic differentation.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions libs/expressions/include/TensorExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace cfem::sym
private:
std::shared_ptr<const CfemExpression> m_components[9];
std::shared_ptr<const CfemExpression> createGradient() const override {
CFEM_ERROR << "Gradient is not yet supported for tensor expressions. It would required a 3rd order tensor which is not implemented.";
CFEM_THROW("Gradient is not yet supported for tensor expressions. It would required a 3rd order tensor which is not implemented.");
return nullptr;
}
std::shared_ptr<const CfemExpression> createTimeDerivative() const override;
Expand All @@ -60,7 +60,7 @@ namespace cfem::sym

for (int i = 0; i < 9; ++i) {
if (!m_components[i] || m_components[i]->getDimension() != 1) {
CFEM_ERROR << "TensorExpression component " << i << " must be a valid scalar expression.";
CFEM_THROW("TensorExpression component " + std::to_string(i) + " must be a valid scalar expression.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions libs/expressions/include/UnaryExpression.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace cfem::sym
// --- Dimension Logic & Validation ---
if (m_op == MathOp::Transpose || m_op == MathOp::Trace ) {
if (m_dimIn != 9) {
CFEM_ERROR << "Transpose/Trace are only defined for dim 9 tensors.";
CFEM_THROW("Transpose/Trace are only defined for dim 9 tensors.");
}
}

Expand Down Expand Up @@ -143,7 +143,7 @@ namespace cfem::sym
for(int i=0; i<m_dimOut; ++i) out[i] = std::riemann_zeta(in_buf[i]);
break;
default:
CFEM_ERROR << "Unsupported math operation.";
CFEM_THROW("Unsupported math operation.");
break;
if (needsBookmark) {
ctx.releaseToBookmark(bookmark);
Expand Down
2 changes: 1 addition & 1 deletion libs/expressions/include/VectorExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace cfem::sym

for (int i = 0; i < 3; ++i) {
if (!m_components[i] || m_components[i]->getDimension() != 1) {
CFEM_ERROR << "VectorExpression component " << i << " must be a valid scalar expression. Got dim = " << m_components[i]->getDimension();
CFEM_THROW("VectorExpression component " << i << " must be a valid scalar expression. Got dim = " << m_components[i]->getDimension() );
}
}

Expand Down
8 changes: 4 additions & 4 deletions libs/expressions/src/LambdaExpressionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ namespace cfem::sym
m_timeDeriv = std::move(timeDeriv);
if (m_gradient){
if (m_dimension == 1 && m_gradient->getDimension() != 3){
CFEM_ERROR << "The gradient of a scalar lambda expression must be a 3D vector.";
CFEM_THROW("The gradient of a scalar lambda expression must be a 3D vector.");
}
if (m_dimension == 3 && m_gradient->getDimension() != 9){
CFEM_ERROR << "The gradient of a vector lambda expression must be a 2nd order tensor (dimension 9).";
CFEM_THROW("The gradient of a vector lambda expression must be a 2nd order tensor (dimension 9).");
}
}

if (m_timeDeriv){
if (m_timeDeriv->getDimension() != m_dimension){
CFEM_ERROR << "The time derivative must have the same dimension ("
<< m_dimension << ") as the lambda expression.";
CFEM_THROW( "The time derivative must have the same dimension ("
<< m_dimension << ") as the lambda expression.");
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion libs/fem/assembly/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ target_include_directories(cfem_assembly
target_link_libraries(cfem_assembly
PUBLIC cfem_petsc_wrappers
cfem_utils
)
cfem_openmp_interface
)
5 changes: 3 additions & 2 deletions libs/fem/fefield/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ target_include_directories(cfem_fefield
)

target_link_libraries(cfem_fefield
PUBLIC
PUBLIC
cfem_openmp_interface
cfem_utils
cfem_petsc_wrappers
cfem_reference_element
cfem_expressions
cfem_mesh
cfem_fespace
)
)
3 changes: 2 additions & 1 deletion libs/fem/fespace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ target_include_directories(cfem_fespace

target_link_libraries(cfem_fespace
PUBLIC
cfem_openmp_interface
cfem_utils
cfem_reference_element
cfem_mesh
cfem_expressions
cfem_fefield
)
)
3 changes: 2 additions & 1 deletion libs/fem/mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ target_include_directories(cfem_mesh

target_link_libraries(cfem_mesh
PUBLIC cfem_utils
)
cfem_openmp_interface
)
3 changes: 2 additions & 1 deletion libs/prepostprocessing/numerical_integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ target_include_directories(cfem_numerical_integration

target_link_libraries(cfem_numerical_integration
PUBLIC cfem_utils
cfem_openmp_interface
cfem_reference_element
cfem_quadrature
cfem_mesh
cfem_fespace
cfem_expressions
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace cfem
m_schemes_params(schemes_params)
{
if (!m_mesh)
CFEM_ERROR << "FunctionIntegrator requires a valid mesh.";
CFEM_THROW("FunctionIntegrator requires a valid mesh.");
}

void FunctionIntegrator::L2Norm(const std::shared_ptr<const sym::CfemExpression> &expr,
Expand Down Expand Up @@ -133,7 +133,7 @@ namespace cfem
const MeshEntity& volume_entity)
{
if( ! m_mesh->isPartOfTheMeshEntities(boundary_entity.getId()) ){
CFEM_ERROR << boundary_entity.getName() << " is not part of the mesh.";
CFEM_THROW(boundary_entity.getName() << " is not part of the mesh.");
}

CfemInt entityDim = boundary_entity.getDimension();
Expand All @@ -143,23 +143,23 @@ namespace cfem
bool isManifoldSurface = (entityDim == 2 && meshDim == 2);

if (!isBoundary && !isManifoldSurface) {
CFEM_ERROR << "computeFlux: Flux can only be computed on a boundary (dim "
CFEM_THROW("computeFlux: Flux can only be computed on a boundary (dim "
<< meshDim - 1 << ") or a surface manifold (dim 2). Target entity '"
<< boundary_entity.getName() << "' has dimension " << entityDim;
<< boundary_entity.getName() << "' has dimension " << entityDim);
}

if (isBoundary) {
if( ! m_mesh->isPartOfTheMeshEntities(volume_entity.getId()) ){
CFEM_ERROR << volume_entity.getName() << " is not part of the mesh.";
CFEM_THROW(volume_entity.getName() << " is not part of the mesh.");
}
if( volume_entity.getDimension() != meshDim) {
CFEM_ERROR << "The body must have the same dimension as the mesh (" << meshDim << ").";
CFEM_THROW("The body must have the same dimension as the mesh (" << meshDim << ").");
}
}

if (expr->getDimension() != 3) {
CFEM_ERROR << "computeFlux: The expression must be a 3D vector. "
<< "Got dimension " << expr->getDimension();
CFEM_THROW("computeFlux: The expression must be a 3D vector. "
<< "Got dimension " << expr->getDimension());
}

auto fluxExpr = sym::dot(expr, sym::geometric_normal());
Expand Down Expand Up @@ -211,8 +211,8 @@ namespace cfem
if (!targets[i].first) continue;

if (targets[i].first->getDimension() != 1) {
CFEM_ERROR << "FunctionIntegrator only accepts scalar expressions. "
<< "Please pass each component separately.";
CFEM_THROW( "FunctionIntegrator only accepts scalar expressions. "
<< "Please pass each component separately.");
}

targets[i].first->prepare();
Expand Down Expand Up @@ -408,8 +408,8 @@ namespace cfem
if (!targets[i].first) continue;

if (targets[i].first->getDimension() != 1) {
CFEM_ERROR << "FunctionIntegrator only accepts scalar expressions. "
<< "Please pass each component separately.";
CFEM_THROW( "FunctionIntegrator only accepts scalar expressions. "
<< "Please pass each component separately.");
}

targets[i].first->prepare();
Expand Down
Loading
Loading