BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
fn_FEM_ghost_switch.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_FN_FEM_GHOST_SWITCH_HPP
13#define BELFEM_FN_FEM_GHOST_SWITCH_HPP
14
15#include "typedefs.hpp"
16#include "assert.hpp"
17#include "cl_InputFile.hpp"
18#include "cl_Input_Section.hpp"
19
20namespace belfem
21{
22 namespace fem
23 {
24//------------------------------------------------------------------------------
25
33 inline const input::Section *
35 {
36 if ( aSolver == nullptr )
37 {
38 return nullptr ;
39 }
40 if ( aSolver->section_exists( "nonlinear magnetic" ) )
41 {
42 return aSolver->section( "nonlinear magnetic" );
43 }
44 if ( aSolver->section_exists( "nonlinear" ) )
45 {
46 return aSolver->section( "nonlinear" );
47 }
48 return nullptr ;
49 }
50
51//------------------------------------------------------------------------------
52
72 inline real
73 read_ghost_eta( const input::Section * aSolver )
74 {
75 const input::Section * tNonLinear = winning_nonlinear_section( aSolver );
76
77 if ( tNonLinear == nullptr
78 || ! tNonLinear->section_exists( "nitsche ghost penalty" ) )
79 {
80 return -1.0 ;
81 }
82
83 const input::Section * tGhost = tNonLinear->section( "nitsche ghost penalty" );
84
85 BELFEM_ERROR( tGhost->key_exists( "eta" ),
86 "a 'nitsche ghost penalty' block requires the key 'eta': a positive value switches "
87 "the ghost coupling of the thin-shell layers on, 'eta : 0' switches it off "
88 "( so does omitting the block ). 'k_reg' alone does not say which." );
89
90 // dimensionless: a dimensioned value ( "eta : 4 mOhm ;" ) is
91 // rejected instead of silently SI-scaled
92 const value tEta = tGhost->get_value( "eta", "-" );
93
94 BELFEM_ERROR( tEta.first >= 0.0, "eta must not be negative, but is %g",
95 ( double ) tEta.first );
96
97 return tEta.first ;
98 }
99
100//------------------------------------------------------------------------------
101
103 inline bool
105 {
106 return read_ghost_eta( aSolver ) > 0.0 ;
107 }
108
109//------------------------------------------------------------------------------
110
113 inline bool
114 ghost_facets_requested( const InputFile & aInputFile )
115 {
116 return aInputFile.section_exists( "solver" ) ?
117 ghost_facets_requested( aInputFile.section( "solver" ) ) : false ;
118 }
119
120//------------------------------------------------------------------------------
121 }
122}
123
124#endif //BELFEM_FN_FEM_GHOST_SWITCH_HPP
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
Parser for the input.conf configuration format.
Definition cl_InputFile.hpp:30
bool section_exists(const string &aSection) const
tell if a section exists
Definition cl_InputFile.cpp:170
const input::Section * section(const string &aSection) const
return a top-level section by type string ( a labelled section is keyed as "type:label" )
Definition cl_InputFile.cpp:146
One hierarchical section of a configuration file.
Definition cl_Input_Section.hpp:34
bool key_exists(const string &aKey) const
check if a key exists
Definition cl_Input_Section.cpp:250
bool section_exists(const string &aType) const
tell if a section exists
Definition cl_Input_Section.hpp:397
const Section * section(const string &aType) const
return a subsection by type string (requires empty label)
Definition cl_Input_Section.cpp:382
value get_value(const string &aKey, const string &aUnit) const
get the real value of a key with unit
Definition cl_Input_Section.cpp:313
Definition cl_IFB_LINE3.hpp:21
bool ghost_facets_requested(const input::Section *aSolver)
true if the deck asks for duplicate interface dofs and ghost facets
Definition fn_FEM_ghost_switch.hpp:104
const input::Section * winning_nonlinear_section(const input::Section *aSolver)
The nonlinear section the penalty blocks are read from: the same alias rule Controller::set_params ap...
Definition fn_FEM_ghost_switch.hpp:34
real read_ghost_eta(const input::Section *aSolver)
The Nitsche ghost switch as the deck states it, read from the solver section:
Definition fn_FEM_ghost_switch.hpp:73
USER GUIDES:
Definition cl_Capacitor.cpp:16
std::pair< real, unit > value
Definition typedefs.hpp:74
double real
Definition typedefs.hpp:36