Skip to content

Commit c33ae17

Browse files
castelletto1rrsettgastjhuang2601MelReyCG
authored
feat: Missed std::map (#3877)
* Missed std::map * Ensuring bounds-checking * Uncrustifying * Typo * Update src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp Co-authored-by: MelReyCG <[email protected]> * Replacing map with stdMap * add manualdockerimage.bash * script changes * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * WIP * Trying again * Again * Again * ... * ... * ... * ... * ... * ... * ... * Again * ... * Last attempt --------- Co-authored-by: Randolph Settgast <[email protected]> Co-authored-by: Jian Huang <[email protected]> Co-authored-by: MelReyCG <[email protected]>
1 parent 6a90f8c commit c33ae17

File tree

4 files changed

+90
-18
lines changed

4 files changed

+90
-18
lines changed

scripts/manualdockerimage.bash

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# --------- CONFIG (edit or pass as env vars) -----------------
5+
: "${APP_IMAGE_REPO:=geosx/geosx_ubuntu22.04-clang15}" # Docker Hub repo to push to
6+
: "${GIT_URL:=git@github.com:GEOS-DEV/GEOS.git}" # SSH repo URL
7+
: "${GIT_REF:=stdMap}" # branch/tag/sha (optional; will try to checkout)
8+
: "${BASE_IMAGE:=geosx/ubuntu22.04-clang15:320-766}" # TPL image to build in
9+
: "${CMAKE_BUILD_TYPE:=Release}"
10+
: "${HOSTCFG:=/spack-generated.cmake}"
11+
: "${ENABLE_HYPRE:=ON}"
12+
: "${ENABLE_TRILINOS:=OFF}"
13+
: "${GEOS_ENABLE_BOUNDS_CHECK:=OFF}"
14+
: "${PLATFORM:=}" # e.g. set to linux/amd64 on Apple Silicon
15+
# -------------------------------------------------------------
16+
17+
# sanity: need an ssh-agent socket to forward
18+
if [[ -z "${SSH_AUTH_SOCK:-}" || ! -S "$SSH_AUTH_SOCK" ]]; then
19+
echo "ERROR: SSH_AUTH_SOCK not set or not a socket. Run: eval \"\$(ssh-agent -s)\" && ssh-add ~/.ssh/id_ed25519" >&2
20+
exit 1
21+
fi
22+
23+
NAME="geosx_build_$(date +%s)"
24+
25+
echo "Base image: ${BASE_IMAGE}"
26+
echo "Repo URL: ${GIT_URL}"
27+
echo "Git ref: ${GIT_REF}"
28+
echo "Output registry: ${APP_IMAGE_REPO}"
29+
30+
docker rm -f "$NAME" >/dev/null 2>&1 || true
31+
docker run -it ${PLATFORM:+--platform="${PLATFORM}"} --name "$NAME" --cap-add=SYS_PTRACE \
32+
-v "$SSH_AUTH_SOCK:/ssh-agent" -e SSH_AUTH_SOCK=/ssh-agent \
33+
-e ENABLE_HYPRE="${ENABLE_HYPRE}" \
34+
-e ENABLE_TRILINOS="${ENABLE_TRILINOS}" \
35+
-e GEOS_BUILD_SHARED_LIBS=ON \
36+
--volume /Users/settgast1/Codes/geos/GEOS_Develop:/src/geosx \
37+
"$BASE_IMAGE"
38+
39+
40+
41+
# # Build & install using your existing CI script
42+
/src/geosx/scripts/ci_build_and_test_in_container.sh --repository /src/geosx --cmake-build-type Release --host-config /spack-generated.cmake --enable-hypre ON --enable-trilinos OFF --geos-enable-bounds-check OFF --install-dir-basename geosx-install --no-run-unit-tests --nproc 4 --ninja
43+
44+
# # Hygiene: drop git metadata so creds aren't baked into the committed image
45+
# rm -rf /src/geosx/.git /src/geosx/.gitmodules || true
46+
# "
47+
48+
# # Grab the short sha that the container wrote
49+
# docker cp "$NAME":/tmp/shortsha ./shortsha || true
50+
# if [ -s ./shortsha ]; then
51+
# SHORT_SHA="$(cat ./shortsha)"
52+
# else
53+
# # Fallback if file missing: use the ref or container ID tail
54+
# SHORT_SHA="${GIT_REF:-$(docker inspect --format='{{.Id}}' "$NAME" | cut -c1-7)}"
55+
# fi
56+
# rm -f ./shortsha
57+
58+
# TAG="${APP_IMAGE_REPO}:${SHORT_SHA}"
59+
60+
# echo "Logging into Docker Hub to push ${TAG} ..."
61+
# docker login
62+
# docker commit --change='ENTRYPOINT []' --change='CMD ["/bin/bash"]' "$NAME" "$TAG"
63+
# docker push "$TAG"
64+
# docker rm "$NAME" || true
65+
66+
# echo "Pushed ${TAG}"

src/coreComponents/fieldSpecification/FieldSpecificationManager.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c
7777
{
7878
localIndex isFieldNameFound = 0;
7979
// map from set name to a flag (1 if targetSet has been created, 0 otherwise)
80-
map< string, localIndex > isTargetSetCreated;
80+
stdMap< string, localIndex > isTargetSetCreated;
8181
MeshObjectPath::SetNameToTypesMap setTypesMap;
8282
// The fieldSpecification target objectType
8383
MeshObjectPath::ObjectTypes const targetElementType = fs.getMeshObjectPaths().getObjectType();
@@ -88,8 +88,8 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c
8888
string_array const & setNames = fs.getSetNames();
8989
for( size_t i = 0; i < setNames.size(); ++i )
9090
{
91-
isTargetSetCreated[setNames[i]] = 0;
92-
setTypesMap[setNames[i]][targetElementType] = 1;
91+
isTargetSetCreated.get_inserted( setNames[i] ) = 0;
92+
setTypesMap.get_inserted( setNames[i] ).get_inserted( targetElementType ) = 1;
9393
}
9494

9595
// We have to make sure that the meshLevel is in the target of the boundary conditions
@@ -129,7 +129,10 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c
129129
}
130130

131131
if( targetSet.size() > 0 )
132-
setTypesMap[setName][targetElementType] = 0;
132+
{
133+
// Use the single set name provided by the callback (setName), not the outer array (setNames)
134+
setTypesMap.get_inserted( setName ).get_inserted( targetElementType ) = 0;
135+
}
133136
} );
134137

135138
// Step 3: MPI synchronization
@@ -216,7 +219,7 @@ void FieldSpecificationManager::validateBoundaryConditions( MeshLevel & mesh ) c
216219
NodeManager >( mesh, setName,
217220
[&setTypesMap]( MeshObjectPath::ObjectTypes managerType,
218221
string const & capturedSetName ){
219-
setTypesMap[capturedSetName][managerType] = 0;
222+
setTypesMap.get_inserted( capturedSetName ).get_inserted( managerType ) = 0;
220223
} );
221224
string_array capturedTypes;
222225
for( auto const & [element, isExisting] : elementsType )

src/coreComponents/mesh/MeshObjectPath.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class MeshObjectPath
6060

6161
/// @brief alias for the map allowing to know the existance of given element types (node, edge, cell...)
6262
/// with localIndex = 0 | 1 ( exist / not existing)
63-
using SetNameToTypesMap = std::map< std::string, std::map< MeshObjectPath::ObjectTypes, localIndex > >;
63+
using SetNameToTypesMap = stdMap< string, stdMap< MeshObjectPath::ObjectTypes, localIndex > >;
6464

6565
/**
6666
* @brief Construct a new Mesh Object Path object

src/coreComponents/schema/schemaUtilities.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,35 +96,38 @@ void AppendSimpleType( xmlWrapper::xmlNode & schemaRoot,
9696
{
9797
string const advanced_match_string = ".*[\\[\\]`$].*|";
9898

99+
// Create simpleType node
99100
xmlWrapper::xmlNode newNode = schemaRoot.append_child( "xsd:simpleType" );
101+
GEOS_ERROR_IF( ( !newNode ), GEOS_FMT( "Failed to create xsd:simpleType node for {}", name ) );
100102
newNode.append_attribute( "name" ) = name.c_str();
103+
104+
// Create restriction node
101105
xmlWrapper::xmlNode restrictionNode = newNode.append_child( "xsd:restriction" );
106+
GEOS_ERROR_IF( ( !restrictionNode ), GEOS_FMT( "Failed to create xsd:restriction node for {}", name ) );
102107
restrictionNode.append_attribute( "base" ) = "xsd:string";
108+
109+
// Create pattern node
103110
xmlWrapper::xmlNode patternNode = restrictionNode.append_child( "xsd:pattern" );
111+
GEOS_ERROR_IF( ( !patternNode ), GEOS_FMT( "Failed to create xsd:pattern node for {}", name ) );
104112

105-
// Handle the default regex
106-
if( regex.empty() )
107-
{
108-
GEOS_WARNING( "schema regex not defined for " << name );
109-
patternNode.append_attribute( "value" ) = "(?s).*";
110-
}
111-
else
112-
{
113-
string const patternString = advanced_match_string + regex;
114-
patternNode.append_attribute( "value" ) = patternString.c_str();
115-
}
113+
// Determine pattern string
114+
GEOS_WARNING_IF( regex.empty(), GEOS_FMT( "schema regex not defined for {}", name ) );
115+
string const patternString = regex.empty() ? "(?s).*" : advanced_match_string + regex;
116+
117+
// Set attribute
118+
patternNode.append_attribute( "value" ) = patternString.c_str();
116119
}
117120

118121
void BuildSimpleSchemaTypes( xmlWrapper::xmlNode schemaRoot )
119122
{
120123
auto const regexes = rtTypes::createBasicTypesRegexMap();
124+
121125
for( auto const & [typeName, regex] : regexes )
122126
{
123127
AppendSimpleType( schemaRoot, getSchemaTypeName( typeName ), regex.m_regexStr );
124128
}
125129
}
126130

127-
128131
void SchemaConstruction( Group & group,
129132
xmlWrapper::xmlNode schemaRoot,
130133
xmlWrapper::xmlNode schemaParent,

0 commit comments

Comments
 (0)