Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
3e276561
Commit
3e276561
authored
17 years ago
by
Mattijs Janssens
Browse files
Options
Downloads
Patches
Plain Diff
Special handling for polyMesh/boundary file
parent
4467097c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/utilities/preProcessing/changeDictionary/changeDictionary.C
+111
-31
111 additions, 31 deletions
...ilities/preProcessing/changeDictionary/changeDictionary.C
with
111 additions
and
31 deletions
applications/utilities/preProcessing/changeDictionary/changeDictionary.C
+
111
−
31
View file @
3e276561
...
@@ -44,16 +44,24 @@ Description
...
@@ -44,16 +44,24 @@ Description
}
}
@endverbatim
@endverbatim
\*---------------------------------------------------------------------------*/
\*---------------------------------------------------------------------------*/
#include
"argList.H"
#include
"argList.H"
#include
"IOobjectList.H"
#include
"IOobjectList.H"
#include
"IOPtrList.H"
#include
"volFields.H"
#include
"volFields.H"
using
namespace
Foam
;
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
defineTemplateTypeNameAndDebug
(
IOPtrList
<
entry
>
,
0
);
}
// Main program:
// Main program:
...
@@ -89,38 +97,110 @@ int main(int argc, char *argv[])
...
@@ -89,38 +97,110 @@ int main(int argc, char *argv[])
const
word
&
fieldName
=
fieldIter
().
keyword
();
const
word
&
fieldName
=
fieldIter
().
keyword
();
Info
<<
"Replacing entries in dictionary "
<<
fieldName
<<
endl
;
Info
<<
"Replacing entries in dictionary "
<<
fieldName
<<
endl
;
// Read dictionary. (disable class type checking so we can load field)
// Handle 'boundary' specially:
Info
<<
"Loading dictionary "
<<
fieldName
<<
endl
;
// - is PtrList of dictionaries
const
word
oldTypeName
=
IOdictionary
::
typeName
;
// - is in polyMesh/
const_cast
<
word
&>
(
IOdictionary
::
typeName
)
=
word
::
null
;
if
(
fieldName
==
"boundary"
)
IOdictionary
fieldDict
{
(
Info
<<
"Special handling of "
<<
fieldName
IOobject
<<
" as polyMesh/boundary file."
<<
endl
;
// Read PtrList of dictionary as dictionary.
const
word
oldTypeName
=
IOPtrList
<
entry
>::
typeName
;
const_cast
<
word
&>
(
IOPtrList
<
entry
>::
typeName
)
=
word
::
null
;
IOPtrList
<
entry
>
dictList
(
(
fieldName
,
IOobject
runTime
.
timeName
(),
(
mesh
,
fieldName
,
IOobject
::
MUST_READ
,
runTime
.
findInstance
(
polyMesh
::
meshSubDir
,
fieldName
),
IOobject
::
NO_WRITE
,
polyMesh
::
meshSubDir
,
false
mesh
,
)
IOobject
::
MUST_READ
,
);
IOobject
::
NO_WRITE
,
const_cast
<
word
&>
(
IOdictionary
::
typeName
)
=
oldTypeName
;
false
// Fake type back to what was in field
)
const_cast
<
word
&>
(
fieldDict
.
type
())
=
fieldDict
.
headerClassName
();
);
const_cast
<
word
&>
(
IOPtrList
<
entry
>::
typeName
)
=
oldTypeName
;
Info
<<
"Loaded dictionary "
<<
fieldName
// Fake type back to what was in field
<<
" with entries "
<<
fieldDict
.
toc
()
<<
endl
;
const_cast
<
word
&>
(
dictList
.
type
())
=
dictList
.
headerClassName
();
// Get the replacement dictionary for the field
// Temporary convert to dictionary
const
dictionary
&
replaceDict
=
fieldIter
().
dict
();
dictionary
fieldDict
;
Info
<<
"Merging entries from "
<<
replaceDict
.
toc
()
<<
endl
;
forAll
(
dictList
,
i
)
{
// Merge the replacements in
fieldDict
.
add
(
dictList
[
i
].
keyword
(),
dictList
[
i
].
dict
());
fieldDict
.
merge
(
replaceDict
);
}
Info
<<
"Writing modified fieldDict "
<<
fieldName
<<
endl
;
Info
<<
"Loaded dictionary "
<<
fieldName
fieldDict
.
regIOobject
::
write
();
<<
" with entries "
<<
fieldDict
.
toc
()
<<
endl
;
// Get the replacement dictionary for the field
const
dictionary
&
replaceDict
=
fieldIter
().
dict
();
Info
<<
"Merging entries from "
<<
replaceDict
.
toc
()
<<
endl
;
// Merge the replacements in
fieldDict
.
merge
(
replaceDict
);
Info
<<
"fieldDict:"
<<
fieldDict
<<
endl
;
// Convert back into dictList
wordList
doneKeys
(
dictList
.
size
());
label
nEntries
=
fieldDict
.
size
();
forAll
(
dictList
,
i
)
{
doneKeys
[
i
]
=
dictList
[
i
].
keyword
();
dictList
.
set
(
i
,
fieldDict
.
lookupEntry
(
doneKeys
[
i
]).
clone
());
fieldDict
.
remove
(
doneKeys
[
i
]);
}
// Add remaining entries
label
sz
=
dictList
.
size
();
dictList
.
setSize
(
nEntries
);
forAllConstIter
(
dictionary
,
fieldDict
,
iter
)
{
dictList
.
set
(
sz
,
iter
().
clone
());
}
Info
<<
"Writing modified fieldDict "
<<
fieldName
<<
endl
;
dictList
.
write
();
}
else
{
// Read dictionary. (disable class type checking so we can load
// field)
Info
<<
"Loading dictionary "
<<
fieldName
<<
endl
;
const
word
oldTypeName
=
IOdictionary
::
typeName
;
const_cast
<
word
&>
(
IOdictionary
::
typeName
)
=
word
::
null
;
IOdictionary
fieldDict
(
IOobject
(
fieldName
,
runTime
.
timeName
(),
mesh
,
IOobject
::
MUST_READ
,
IOobject
::
NO_WRITE
,
false
)
);
const_cast
<
word
&>
(
IOdictionary
::
typeName
)
=
oldTypeName
;
// Fake type back to what was in field
const_cast
<
word
&>
(
fieldDict
.
type
())
=
fieldDict
.
headerClassName
();
Info
<<
"Loaded dictionary "
<<
fieldName
<<
" with entries "
<<
fieldDict
.
toc
()
<<
endl
;
// Get the replacement dictionary for the field
const
dictionary
&
replaceDict
=
fieldIter
().
dict
();
Info
<<
"Merging entries from "
<<
replaceDict
.
toc
()
<<
endl
;
// Merge the replacements in
fieldDict
.
merge
(
replaceDict
);
Info
<<
"Writing modified fieldDict "
<<
fieldName
<<
endl
;
fieldDict
.
regIOobject
::
write
();
}
}
}
Info
<<
endl
;
Info
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment